Skip to content

Commit

Permalink
feat: support erc721 and erc1155 (#11551)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed May 8, 2024
1 parent 1b49479 commit 89b1c35
Show file tree
Hide file tree
Showing 15 changed files with 825 additions and 456 deletions.
33 changes: 33 additions & 0 deletions packages/mask-sdk/shared/error-generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ export enum ErrorMessages {
json_rpc_version_not_supported = "JSON-RPC version not supported",
invalid_request = "Invalid request",
the_method_eth_subscribe_is_only_available_on_the_mainnet = "The method \"eth_subscribe\" is only available on the mainnet.",
invalid_address = "Invalid address",
invalid_params = "Invalid params",
wallet_request_permissions_a_permission_request_must_contain_at_least_1_permission = "A permission request must contain at least 1 permission.",
wallet_watch_asset_a_symbol_is_required_but_was_not_found_in_either_the_request_or_contract = "A symbol is required, but was not found in either the request or contract",
wallet_watch_asset_decimals_are_required_but_were_not_found_in_either_the_request_or_contract = "Decimals are required, but were not found in either the request or contract",
wallet_watch_asset_the_token_address_seems_invalid = "The token address seems invalid",
wallet_watch_asset_unable_to_verify_ownership_possibly_because_the_standard_is_not_supported_or_the_users_currently_selected_network_does_not_match_the_chain_of_the_asset_in_question = "Unable to verify ownership. Possibly because the standard is not supported or the user's currently selected network does not match the chain of the asset in question.",
internal_error = "Internal error",
parse_error = "Parse error",
user_rejected_the_request = "User rejected the request",
Expand All @@ -41,8 +46,13 @@ const codeMap = {
"JSON-RPC version not supported": -32006,
"Invalid request": -32600,
"The method \"eth_subscribe\" is only available on the mainnet.": -32601,
"Invalid address": -32602,
"Invalid params": -32602,
"A permission request must contain at least 1 permission.": -32602,
"A symbol is required, but was not found in either the request or contract": -32602,
"Decimals are required, but were not found in either the request or contract": -32602,
"The token address seems invalid": -32602,
"Unable to verify ownership. Possibly because the standard is not supported or the user's currently selected network does not match the chain of the asset in question.": -32602,
"Internal error": -32603,
"Parse error": -32700,
"User rejected the request": 4001,
Expand Down Expand Up @@ -83,6 +93,9 @@ export const err = {
the_method_eth_subscribe_is_only_available_on_the_mainnet(options: MaskEthereumProviderRpcErrorOptions = {}) {
return new MaskEthereumProviderRpcError(-32601, "The method \"eth_subscribe\" is only available on the mainnet.", options)
},
invalid_address(options: MaskEthereumProviderRpcErrorOptions = {}) {
return new MaskEthereumProviderRpcError(-32602, "Invalid address", options)
},
invalid_params(options: MaskEthereumProviderRpcErrorOptions = {}) {
return new MaskEthereumProviderRpcError(-32602, "Invalid params", options)
},
Expand All @@ -94,6 +107,26 @@ export const err = {
return new MaskEthereumProviderRpcError(-32602, `Permission request contains unsupported permission ${permission}.`, options)
},
},
wallet_watchAsset: {
a_symbol_is_required_but_was_not_found_in_either_the_request_or_contract(options: MaskEthereumProviderRpcErrorOptions = {}) {
return new MaskEthereumProviderRpcError(-32602, "A symbol is required, but was not found in either the request or contract", options)
},
decimals_are_required_but_were_not_found_in_either_the_request_or_contract(options: MaskEthereumProviderRpcErrorOptions = {}) {
return new MaskEthereumProviderRpcError(-32602, "Decimals are required, but were not found in either the request or contract", options)
},
the_decimals_in_the_request_request_do_not_match_the_decimals_in_the_contract_decimals({ request, decimals }: Record<"request" | "decimals", string>,options: MaskEthereumProviderRpcErrorOptions = {}) {
return new MaskEthereumProviderRpcError(-32602, `The decimals in the request (${request}) do not match the decimals in the contract (${decimals})`, options)
},
the_symbol_in_the_request_request_does_not_match_the_symbol_in_the_contract_symbol({ request, symbol }: Record<"request" | "symbol", string>,options: MaskEthereumProviderRpcErrorOptions = {}) {
return new MaskEthereumProviderRpcError(-32602, `The symbol in the request (${request}) does not match the symbol in the contract (${symbol})`, options)
},
the_token_address_seems_invalid(options: MaskEthereumProviderRpcErrorOptions = {}) {
return new MaskEthereumProviderRpcError(-32602, "The token address seems invalid", options)
},
unable_to_verify_ownership_possibly_because_the_standard_is_not_supported_or_the_users_currently_selected_network_does_not_match_the_chain_of_the_asset_in_question(options: MaskEthereumProviderRpcErrorOptions = {}) {
return new MaskEthereumProviderRpcError(-32602, "Unable to verify ownership. Possibly because the standard is not supported or the user's currently selected network does not match the chain of the asset in question.", options)
},
},
internal_error(options: MaskEthereumProviderRpcErrorOptions = {}) {
return new MaskEthereumProviderRpcError(-32603, "Internal error", options)
},
Expand Down
7 changes: 7 additions & 0 deletions packages/mask-sdk/shared/messages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
-32600 Invalid request
-32601 The method "${method}" does not exist / is not available.
-32602 Invalid params
-32602 Invalid address
-32602 wallet_watchAsset A symbol is required, but was not found in either the request or contract
-32602 wallet_watchAsset Decimals are required, but were not found in either the request or contract
-32602 wallet_watchAsset Unable to verify ownership. Possibly because the standard is not supported or the user's currently selected network does not match the chain of the asset in question.
-32602 wallet_watchAsset The token address seems invalid
-32602 wallet_watchAsset The symbol in the request (${request}) does not match the symbol in the contract (${symbol})
-32602 wallet_watchAsset The decimals in the request (${request}) do not match the decimals in the contract (${decimals})
-32602 wallet_requestPermissions A permission request must contain at least 1 permission.
-32602 wallet_requestPermissions Permission request contains unsupported permission ${permission}.
-32603 Internal error
Expand Down

0 comments on commit 89b1c35

Please sign in to comment.