Skip to content

Commit

Permalink
'bump'
Browse files Browse the repository at this point in the history
  • Loading branch information
tenbits committed Nov 23, 2023
1 parent ea08c13 commit 9d45fa5
Show file tree
Hide file tree
Showing 3 changed files with 449 additions and 37 deletions.
242 changes: 224 additions & 18 deletions lib/0xweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -13224,10 +13224,13 @@ var $rpc;
return receipt;
}
$rpc.waitForReceipt = waitForReceipt;
function deserialize(model, schema) {
function deserialize(model, schema, schemas) {
if (model == null) {
return model;
}
if (typeof schema === 'string' && schemas != null && schema in schemas) {
schema = schemas[schema];
}
let type = schema;
if (typeof schema === 'string') {
switch (type) {
Expand All @@ -13237,28 +13240,42 @@ var $rpc;
return BigInt(model);
case 'boolean':
return Boolean(model);
case 'string':
return model;
}
}
if (Array.isArray(schema)) {
_require_1.$require.True(schema.length === 1, `Schema length must be 1 (the type): ${schema}`);
if (Array.isArray(model) === false) {
throw new Error(`Result must be an array: ${JSON.stringify(model)}`);
}
return model.map(x => deserialize(x, schema[0]));
return model.map(x => deserialize(x, schema[0], schemas));
}
if (typeof schema === 'object') {
let modelType = typeof model;
if ('oneOf' in schema) {
let oneOf = schema.oneOf.find(x => typeof x === modelType);
let oneOf = schema.oneOf.find(x => {
if (Array.isArray(x) && Array.isArray(model)) {
let baseType = x[0];
if (baseType === modelType) {
return true;
}
if (modelType === 'object' && /^[A-Z]/.test(baseType)) {
return true;
}
return false;
}
return typeof x === modelType;
});
if (oneOf) {
return deserialize(model, oneOf);
return deserialize(model, oneOf, schemas);
}
return model;
}
if (modelType === 'object') {
let out = {};
for (let key in model) {
out[key] = deserialize(model[key], schema[key]);
out[key] = deserialize(model[key], schema[key], schemas);
}
return out;
}
Expand Down Expand Up @@ -14086,7 +14103,7 @@ class RpcFunction {
if (typeof returnsSchema === 'function') {
return returnsSchema(result);
}
return _rpc_1.$rpc.deserialize(result, returnsSchema);
return _rpc_1.$rpc.deserialize(result, returnsSchema, this.methodInfo.schemas);
}
return result;
};
Expand Down Expand Up @@ -14167,7 +14184,10 @@ class RpcBase {
}
extend(rpcInfos) {
rpcInfos.forEach(rpcInfo => {
let fn = new RpcFunction_1.RpcFunction(this, rpcInfo);
let fn = new RpcFunction_1.RpcFunction(this, {
...rpcInfo,
schemas: this.returnSchemas?.schemas
});
this.fns[rpcInfo.name] = fn.caller();
});
}
Expand Down Expand Up @@ -14215,7 +14235,7 @@ class RpcBase {
if (schema == null || result == null) {
return result;
}
return _rpc_1.$rpc.deserialize(result, schema);
return _rpc_1.$rpc.deserialize(result, schema, this.returnSchemas?.schemas);
}
}
exports.RpcBase = RpcBase;
Expand Down Expand Up @@ -14485,6 +14505,25 @@ class Rpc extends RpcBase_1.RpcBase {
}
},
"schemas": {
"AddEthereumChainParameter": {
"chainId": "string",
"blockExplorerUrls": [
"string"
],
"chainName": "string",
"iconUrls": [
"string"
],
"nativeCurrency": "NativeCurrency",
"rpcUrls": [
"string"
]
},
"NativeCurrency": {
"decimals": "bigint",
"name": "string",
"symbol": "string"
},
"Permission": {
"id": "string",
"@context": [
Expand All @@ -14498,6 +14537,47 @@ class Rpc extends RpcBase_1.RpcBase {
}
]
},
"TypedData": {
"types": {},
"domain": {},
"primaryType": "string",
"message": {}
},
"GenericTransaction": {
"type": "number",
"nonce": "bigint",
"to": "string",
"from": "string",
"gas": "bigint",
"value": "bigint",
"input": "string",
"gasPrice": "bigint",
"maxPriorityFeePerGas": "bigint",
"maxFeePerGas": "bigint",
"accessList": [
"AccessListEntry"
],
"chainId": "bigint"
},
"AccessListEntry": {
"address": "string",
"storageKeys": [
"string"
]
},
"BlockNumberOrTagOrHash": {
"oneOf": [
"bigint",
"string",
"string"
]
},
"BlockNumberOrTag": {
"oneOf": [
"bigint",
"string"
]
},
"Block": {
"hash": "string",
"parentHash": "string",
Expand Down Expand Up @@ -14536,6 +14616,101 @@ class Rpc extends RpcBase_1.RpcBase {
"string"
]
},
"TransactionInfo": {
"allOf": [
{
"blockHash": "string",
"blockNumber": "number",
"from": "string",
"hash": "string",
"transactionIndex": "number"
},
"TransactionSigned"
]
},
"TransactionSigned": {
"oneOf": [
"Transaction1559Signed",
"Transaction2930Signed",
"TransactionLegacySigned"
]
},
"Transaction1559Signed": {
"allOf": [
"Transaction1559Unsigned",
{
"yParity": "number",
"v": "number",
"r": "string",
"s": "string"
}
]
},
"Transaction1559Unsigned": {
"type": "number",
"nonce": "number",
"to": "string",
"gas": "bigint",
"value": "bigint",
"input": "string",
"maxPriorityFeePerGas": "bigint",
"maxFeePerGas": "bigint",
"gasPrice": "bigint",
"accessList": [
"AccessListEntry"
],
"chainId": "number"
},
"Transaction2930Signed": {
"allOf": [
"Transaction2930Unsigned",
{
"yParity": "number",
"v": "number",
"r": "string",
"s": "string"
}
]
},
"Transaction2930Unsigned": {
"type": "number",
"nonce": "number",
"to": "string",
"gas": "bigint",
"value": "bigint",
"input": "string",
"gasPrice": "bigint",
"accessList": [
"AccessListEntry"
],
"chainId": "number"
},
"TransactionLegacySigned": {
"allOf": [
"TransactionLegacyUnsigned",
{
"v": "number",
"r": "string",
"s": "string"
}
]
},
"TransactionLegacyUnsigned": {
"type": "number",
"nonce": "number",
"to": "string",
"gas": "bigint",
"value": "bigint",
"input": "string",
"gasPrice": "bigint",
"chainId": "number"
},
"Withdrawal": {
"index": "bigint",
"validatorIndex": "bigint",
"address": "string",
"amount": "bigint"
},
"FilterResults": {
"oneOf": [
[
Expand All @@ -14546,6 +14721,42 @@ class Rpc extends RpcBase_1.RpcBase {
]
]
},
"Log": {
"removed": "boolean",
"logIndex": "number",
"transactionIndex": "number",
"transactionHash": "string",
"blockHash": "string",
"blockNumber": "number",
"address": "string",
"data": "string",
"topics": [
"string"
]
},
"Filter": {
"fromBlock": "number",
"toBlock": "number",
"address": {
"oneOf": [
"string",
[
"string"
]
]
},
"topics": [
"FilterTopic"
]
},
"FilterTopic": {
"oneOf": [
"string",
[
"string"
]
]
},
"AccountProof": {
"address": "string",
"accountProof": [
Expand All @@ -14559,16 +14770,11 @@ class Rpc extends RpcBase_1.RpcBase {
"StorageProof"
]
},
"TransactionInfo": {
"allOf": [
{
"blockHash": "string",
"blockNumber": "number",
"from": "string",
"hash": "string",
"transactionIndex": "number"
},
"TransactionSigned"
"StorageProof": {
"key": "string",
"value": "bigint",
"proof": [
"string"
]
},
"ReceiptInfo": {
Expand Down
Loading

0 comments on commit 9d45fa5

Please sign in to comment.