Skip to content

Commit

Permalink
feat: add palm network support. (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
b4rtaz authored Dec 1, 2022
1 parent 1310a8b commit 0cefcef
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-numbers-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@moralisweb3/common-evm-utils': patch
---

Removed the duplicated `apiId` property from the `EvmChain` type.
5 changes: 5 additions & 0 deletions .changeset/mean-nails-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@moralisweb3/common-evm-utils': patch
---

Added the PALM network to the `EvmChain` type.
2 changes: 1 addition & 1 deletion packages/auth/src/methods/requestMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const makeEvmRequestMessage = (
{ chain, address, networkType, network, ...options }: RequestMessageEvmOptions,
) => {
return new OperationResolver(requestChallengeEvmOperation, BASE_URL, core).fetch({
chainId: EvmChain.create(chain).apiId,
chainId: EvmChain.create(chain).hex,
address: EvmAddress.create(address).checksum,
...options,
});
Expand Down
39 changes: 16 additions & 23 deletions packages/common/evmUtils/src/dataTypes/EvmChain/EvmChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export class EvmChain implements MoralisData, EvmChainable {
return EvmChain.create(5);
}

/**
* Returns SEPOLIA chain
*
* @example EvmChain.SEPOLIA
*/
public static get SEPOLIA() {
return EvmChain.create(11155111);
}
Expand Down Expand Up @@ -127,6 +132,15 @@ export class EvmChain implements MoralisData, EvmChainable {
return EvmChain.create(338);
}

/**
* Returns PALM chain
*
* @example EvmChain.PALM
*/
public static get PALM() {
return EvmChain.create(11297108109);
}

/**
* Create a new instance of EvmChain from any valid address input.
*
Expand Down Expand Up @@ -296,29 +310,8 @@ export class EvmChain implements MoralisData, EvmChainable {
| '0xa869'
| '0xfa'
| '0x19'
| '0x152';
}

/**
* Validate and cast to api compatible id
*
* @example chain.apiId // 1
*/
get apiId() {
return this._value as
| '1'
| '5'
| '25'
| '56'
| '97'
| '137'
| '250'
| '338'
| '1337'
| '43113'
| '43114'
| '80001'
| '11155111';
| '0x152'
| '0x2a15c308d';
}

/**
Expand Down
53 changes: 46 additions & 7 deletions packages/common/evmUtils/src/operations/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export interface paths {
/**
* Resync the metadata for an NFT
* * The metadata flag will request the NFT's metadata from an already existing token_uri
* * The URI (default) flag will fetch the latest token_uri from the given NFT contract address. In sync mode the metadata will also be fetched
* * The uri (default) flag will fetch the latest token_uri from the given NFT contract address. In sync mode the metadata will also be fetched
* * The sync mode will make the endpoint synchronous so it will wait for the task to be completed before responding
* * The async mode (default) will make the endpoint asynchronous so we will wait for the task to be completed before responding
*/
Expand Down Expand Up @@ -136,6 +136,10 @@ export interface paths {
/** Get native transactions ordered by block number in descending order. */
get: operations["getWalletTransactions"];
};
"/{address}/verbose": {
/** Get native transactions ordered by block number in descending order. */
get: operations["getWalletTransactions"];
};
"/transaction/{transaction_hash}": {
/** Get the contents of a transaction by the given transaction hash. */
get: operations["getTransaction"];
Expand All @@ -153,11 +157,11 @@ export interface paths {
get: operations["getContractLogs"];
};
"/{address}/events": {
/** Get events for a contract ordered by block number in descending order. */
/** Get events for a contract ordered by block number in descending order. [Try it with Swagger](https://deep-index.moralis.io/api-docs-2.1/#/Events/getContractEvents). */
post: operations["getContractEvents"];
};
"/{address}/function": {
/** Run a given function of a contract ABI and retrieve readonly data. */
/** Run a given function of a contract ABI and retrieve readonly data. [Try it with Swagger](https://deep-index.moralis.io/api-docs-2.1/#/Utils/runContractFunction). */
post: operations["runContractFunction"];
};
"/web3/version": {
Expand Down Expand Up @@ -502,6 +506,21 @@ export interface components {
* @example 1577836811
*/
timestamp: number;
/**
* @description The timestamp of the block
* @example 2022-01-03T22:59:39.000Z
*/
block_timestamp?: number;
/**
* @description The block hash
* @example 0x9b559aef7ea858608c2e554246fe4a24287e7aeeb976848df2b9a2531f4b9171
*/
block_hash?: string;
/**
* @description The block hash of the parent block
* @example 0x011d1fc45839de975cc55d758943f9f1d204f80a90eb631f3bf064b80d53e045
*/
parent_hash?: string;
};
RunContractDto: {
/**
Expand Down Expand Up @@ -533,6 +552,24 @@ export interface components {
page_size?: number;
result?: components["schemas"]["transaction"][];
};
transactionCollectionVerbose: {
/**
* @description The total number of matches for this query
* @example 2000
*/
total?: number;
/**
* @description The current page of the result
* @example 2
*/
page?: number;
/**
* @description The number of results per page
* @example 100
*/
page_size?: number;
result?: components["schemas"]["blockTransaction"][];
};
transaction: {
/**
* @description The hash of the transaction
Expand Down Expand Up @@ -760,6 +797,8 @@ export interface components {
| "0xa869"
| "fantom"
| "0xfa"
| "palm"
| "0x2a15c308d"
| "cronos"
| "0x19"
| "cronos testnet"
Expand Down Expand Up @@ -2071,7 +2110,7 @@ export interface operations {
/**
* Resync the metadata for an NFT
* * The metadata flag will request the NFT's metadata from an already existing token_uri
* * The URI (default) flag will fetch the latest token_uri from the given NFT contract address. In sync mode the metadata will also be fetched
* * The uri (default) flag will fetch the latest token_uri from the given NFT contract address. In sync mode the metadata will also be fetched
* * The sync mode will make the endpoint synchronous so it will wait for the task to be completed before responding
* * The async mode (default) will make the endpoint asynchronous so we will wait for the task to be completed before responding
*/
Expand Down Expand Up @@ -2502,7 +2541,7 @@ export interface operations {
/** Returns a collection of native transactions. */
200: {
content: {
"application/json": components["schemas"]["transactionCollection"];
"application/json": components["schemas"]["transactionCollectionVerbose"];
};
};
};
Expand Down Expand Up @@ -2641,7 +2680,7 @@ export interface operations {
};
};
};
/** Get events for a contract ordered by block number in descending order. */
/** Get events for a contract ordered by block number in descending order. [Try it with Swagger](https://deep-index.moralis.io/api-docs-2.1/#/Events/getContractEvents). */
getContractEvents: {
parameters: {
query: {
Expand Down Expand Up @@ -2719,7 +2758,7 @@ export interface operations {
};
};
};
/** Run a given function of a contract ABI and retrieve readonly data. */
/** Run a given function of a contract ABI and retrieve readonly data. [Try it with Swagger](https://deep-index.moralis.io/api-docs-2.1/#/Utils/runContractFunction). */
runContractFunction: {
parameters: {
query: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ function deserializeResponse(
gasPrice: transfer.gas_price,
gasUsed: transfer.receipt_gas_used,
index: +transfer.transaction_index,
contractAddress: transfer.receipt_contract_address,
receiptRoot: transfer.receipt_root,
contractAddress: transfer.receipt_contract_address as string | null,
receiptRoot: transfer.receipt_root as string | null,
receiptStatus: +transfer.receipt_status,
chain: EvmChainResolver.resolve(request.chain, core),
data: transfer.input,
Expand All @@ -130,8 +130,8 @@ function deserializeResponse(
blockHash: transfer.block_hash,
blockNumber: +transfer.block_number,
blockTimestamp: new Date(transfer.block_timestamp),
gas: BigNumber.create(transfer.gas),
to: transfer.to_address,
gas: transfer.gas ? BigNumber.create(transfer.gas as string) : null,
to: transfer.to_address ? (transfer.to_address as string) : null,
},
core,
),
Expand Down

1 comment on commit 0cefcef

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage

Title Lines Statements Branches Functions
api-utils Coverage: 25%
26.34% (49/186) 19.14% (9/47) 22.85% (8/35)
auth Coverage: 90%
92.77% (77/83) 81.81% (18/22) 90% (18/20)
evm-api Coverage: 100%
100% (79/79) 66.66% (6/9) 100% (47/47)
common-evm-utils Coverage: 64%
65% (938/1443) 19.8% (123/621) 35.89% (201/560)
sol-api Coverage: 96%
96.66% (29/30) 66.66% (6/9) 91.66% (11/12)
common-sol-utils Coverage: 74%
73.77% (135/183) 60% (12/20) 65.67% (44/67)
common-streams-utils Coverage: 93%
93.13% (787/845) 85.96% (196/228) 84.14% (276/328)
streams Coverage: 87%
86.71% (398/459) 67.14% (47/70) 84.52% (71/84)

Please sign in to comment.