@0xsequence/marketplace-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/chunk-3TYUQEFM.js +115 -0
- package/dist/chunk-3TYUQEFM.js.map +1 -0
- package/dist/chunk-4ESPWOBV.js +13 -0
- package/dist/chunk-4ESPWOBV.js.map +1 -0
- package/dist/chunk-4PFMUVE4.js +78 -0
- package/dist/chunk-4PFMUVE4.js.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-5WRI5ZAA.js.map +1 -0
- package/dist/chunk-6S4FYXP6.js +43 -0
- package/dist/chunk-6S4FYXP6.js.map +1 -0
- package/dist/chunk-7OO74L2K.js +41 -0
- package/dist/chunk-7OO74L2K.js.map +1 -0
- package/dist/chunk-BBB3XUB4.js +213 -0
- package/dist/chunk-BBB3XUB4.js.map +1 -0
- package/dist/chunk-BCNFYVAL.js +1 -0
- package/dist/chunk-BCNFYVAL.js.map +1 -0
- package/dist/chunk-D7QQP6MS.js +2 -0
- package/dist/chunk-D7QQP6MS.js.map +1 -0
- package/dist/chunk-DBFOPEV6.js +23 -0
- package/dist/chunk-DBFOPEV6.js.map +1 -0
- package/dist/chunk-EDTC7UES.js +176 -0
- package/dist/chunk-EDTC7UES.js.map +1 -0
- package/dist/chunk-G3D572BT.js +249 -0
- package/dist/chunk-G3D572BT.js.map +1 -0
- package/dist/chunk-HGBEC3WX.js +1285 -0
- package/dist/chunk-HGBEC3WX.js.map +1 -0
- package/dist/chunk-MJ4YU7RW.js +2 -0
- package/dist/chunk-MJ4YU7RW.js.map +1 -0
- package/dist/chunk-NJ2GXOPW.js +2 -0
- package/dist/chunk-NJ2GXOPW.js.map +1 -0
- package/dist/chunk-O5JXKTWP.js +1029 -0
- package/dist/chunk-O5JXKTWP.js.map +1 -0
- package/dist/chunk-O642NH7U.js +15 -0
- package/dist/chunk-O642NH7U.js.map +1 -0
- package/dist/chunk-QOJXWHRZ.js +71 -0
- package/dist/chunk-QOJXWHRZ.js.map +1 -0
- package/dist/chunk-QVFMD6S2.js +21 -0
- package/dist/chunk-QVFMD6S2.js.map +1 -0
- package/dist/chunk-RNUHUVLC.js +214 -0
- package/dist/chunk-RNUHUVLC.js.map +1 -0
- package/dist/chunk-SM7V6ZWI.js +2740 -0
- package/dist/chunk-SM7V6ZWI.js.map +1 -0
- package/dist/chunk-STO74F2I.js +14 -0
- package/dist/chunk-STO74F2I.js.map +1 -0
- package/dist/chunk-TZGLKJRF.js +198 -0
- package/dist/chunk-TZGLKJRF.js.map +1 -0
- package/dist/chunk-UYRQ5MJQ.js +1027 -0
- package/dist/chunk-UYRQ5MJQ.js.map +1 -0
- package/dist/chunk-VPGWEMWL.js +162 -0
- package/dist/chunk-VPGWEMWL.js.map +1 -0
- package/dist/chunk-ZE2LNX65.js +394 -0
- package/dist/chunk-ZE2LNX65.js.map +1 -0
- package/dist/create-config-Dz0gCiQ0.d.ts +8 -0
- package/dist/get-query-client-D46hbjk6.d.ts +5 -0
- package/dist/index.css +232 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/marketplace-config-DZbtyrma.d.ts +57 -0
- package/dist/marketplace.gen-Ceofb9Cs.d.ts +904 -0
- package/dist/react/_internal/api/index.d.ts +51 -0
- package/dist/react/_internal/api/index.js +134 -0
- package/dist/react/_internal/api/index.js.map +1 -0
- package/dist/react/_internal/index.d.ts +22 -0
- package/dist/react/_internal/index.js +150 -0
- package/dist/react/_internal/index.js.map +1 -0
- package/dist/react/_internal/wagmi/index.d.ts +12 -0
- package/dist/react/_internal/wagmi/index.js +12 -0
- package/dist/react/_internal/wagmi/index.js.map +1 -0
- package/dist/react/hooks/index.d.ts +381 -0
- package/dist/react/hooks/index.js +82 -0
- package/dist/react/hooks/index.js.map +1 -0
- package/dist/react/index.css +233 -0
- package/dist/react/index.css.map +1 -0
- package/dist/react/index.d.ts +27 -0
- package/dist/react/index.js +113 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/ssr/index.d.ts +94 -0
- package/dist/react/ssr/index.js +351 -0
- package/dist/react/ssr/index.js.map +1 -0
- package/dist/react/ui/icons/index.css +25 -0
- package/dist/react/ui/icons/index.css.map +1 -0
- package/dist/react/ui/icons/index.d.ts +2 -0
- package/dist/react/ui/icons/index.js +12 -0
- package/dist/react/ui/icons/index.js.map +1 -0
- package/dist/react/ui/index.css +233 -0
- package/dist/react/ui/index.css.map +1 -0
- package/dist/react/ui/index.d.ts +112 -0
- package/dist/react/ui/index.js +34 -0
- package/dist/react/ui/index.js.map +1 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.css +44 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +31 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +39 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.js.map +1 -0
- package/dist/react/ui/styles/index.css +36 -0
- package/dist/react/ui/styles/index.css.map +1 -0
- package/dist/react/ui/styles/index.d.ts +5 -0
- package/dist/react/ui/styles/index.js +13 -0
- package/dist/react/ui/styles/index.js.map +1 -0
- package/dist/sdk-config-xWkdBdrL.d.ts +24 -0
- package/dist/services-BIwQ1C1c.d.ts +20 -0
- package/dist/styles/index.css +233 -0
- package/dist/styles/index.css.map +1 -0
- package/dist/styles/index.d.ts +58 -0
- package/dist/styles/index.js +5019 -0
- package/dist/styles/index.js.map +1 -0
- package/dist/styles.css-BVaTR5nO.d.ts +3 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +39 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types-BrAQ8-w4.d.ts +12 -0
- package/dist/utils/abi/abi/standard/index.d.ts +25 -0
- package/dist/utils/abi/abi/standard/index.js +8 -0
- package/dist/utils/abi/abi/standard/index.js.map +1 -0
- package/dist/utils/abi/abi/token/index.d.ts +1125 -0
- package/dist/utils/abi/abi/token/index.js +13 -0
- package/dist/utils/abi/abi/token/index.js.map +1 -0
- package/dist/utils/abi/clients/index.d.ts +27 -0
- package/dist/utils/abi/clients/index.js +13 -0
- package/dist/utils/abi/clients/index.js.map +1 -0
- package/dist/utils/index.d.ts +23 -0
- package/dist/utils/index.js +37 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +74 -0
- package/src/consts.ts +2 -0
- package/src/index.ts +3 -0
- package/src/react/_internal/api/get-query-client.ts +32 -0
- package/src/react/_internal/api/index.ts +5 -0
- package/src/react/_internal/api/marketplace-api.ts +31 -0
- package/src/react/_internal/api/marketplace.gen.ts +1911 -0
- package/src/react/_internal/api/query-keys.ts +61 -0
- package/src/react/_internal/api/services.ts +101 -0
- package/src/react/_internal/consts.ts +1 -0
- package/src/react/_internal/get-provider.ts +6 -0
- package/src/react/_internal/index.ts +5 -0
- package/src/react/_internal/types.ts +13 -0
- package/src/react/_internal/wagmi/create-config.ts +62 -0
- package/src/react/_internal/wagmi/embedded.ts +87 -0
- package/src/react/_internal/wagmi/index.ts +3 -0
- package/src/react/_internal/wagmi/universal.ts +82 -0
- package/src/react/hooks/index.ts +17 -0
- package/src/react/hooks/options/marketplaceConfigOptions.ts +62 -0
- package/src/react/hooks/useBalanceOfCollectible.tsx +51 -0
- package/src/react/hooks/useCollectible.tsx +47 -0
- package/src/react/hooks/useCollection.tsx +42 -0
- package/src/react/hooks/useCollectionCounts.tsx +61 -0
- package/src/react/hooks/useConfig.tsx +15 -0
- package/src/react/hooks/useCurrencies.tsx +76 -0
- package/src/react/hooks/useFilters.tsx +39 -0
- package/src/react/hooks/useFloorOrder.tsx +28 -0
- package/src/react/hooks/useGenerateListingTransaction.tsx +63 -0
- package/src/react/hooks/useGenerateOfferTransaction.tsx +60 -0
- package/src/react/hooks/useGenerateSellTransaction.tsx +43 -0
- package/src/react/hooks/useHighestOffer.tsx +46 -0
- package/src/react/hooks/useListBalances.tsx +56 -0
- package/src/react/hooks/useListCollectibles.tsx +54 -0
- package/src/react/hooks/useListOffersForCollectible.tsx +53 -0
- package/src/react/hooks/useLowestListing.tsx +47 -0
- package/src/react/hooks/useMarketplaceConfig.tsx +10 -0
- package/src/react/hooks/useRoyaltyPercentage.tsx +45 -0
- package/src/react/hooks/useTransferTokens.tsx +81 -0
- package/src/react/index.ts +5 -0
- package/src/react/provider.tsx +24 -0
- package/src/react/ssr/create-ssr-client.ts +31 -0
- package/src/react/ssr/index.ts +1 -0
- package/src/react/ui/icons/ArrowUp.tsx +29 -0
- package/src/react/ui/icons/CalendarIcon.tsx +29 -0
- package/src/react/ui/icons/InfoIcon.tsx +36 -0
- package/src/react/ui/icons/InventoryIcon.tsx +41 -0
- package/src/react/ui/icons/MinusIcon.tsx +31 -0
- package/src/react/ui/icons/PlusIcon.tsx +29 -0
- package/src/react/ui/icons/PositiveCircleIcon.tsx +35 -0
- package/src/react/ui/icons/index.ts +7 -0
- package/src/react/ui/icons/styles.css.ts +35 -0
- package/src/react/ui/index.ts +6 -0
- package/src/react/ui/modals/Account/index.tsx +29 -0
- package/src/react/ui/modals/CreateListingModal/_store.ts +326 -0
- package/src/react/ui/modals/CreateListingModal/_utils/getCreateListingTransactionTitleMessage.ts +30 -0
- package/src/react/ui/modals/CreateListingModal/index.tsx +146 -0
- package/src/react/ui/modals/MakeOfferModal/_store.ts +296 -0
- package/src/react/ui/modals/MakeOfferModal/_utils/getMakeOfferTransactionTitleMessage.ts +28 -0
- package/src/react/ui/modals/MakeOfferModal/index.tsx +157 -0
- package/src/react/ui/modals/SellModal/_store.ts +274 -0
- package/src/react/ui/modals/SellModal/_utils/getSellTransactionTitleMessage.ts +28 -0
- package/src/react/ui/modals/SellModal/index.tsx +126 -0
- package/src/react/ui/modals/SellModal/utils.ts +38 -0
- package/src/react/ui/modals/SuccessfulPurchaseModal/_store.ts +58 -0
- package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +186 -0
- package/src/react/ui/modals/SuccessfulPurchaseModal/styles.css.ts +52 -0
- package/src/react/ui/modals/TransferModal/_store.ts +58 -0
- package/src/react/ui/modals/TransferModal/_utils/getTransferTransactionTitleMessage.ts +28 -0
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +102 -0
- package/src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx +130 -0
- package/src/react/ui/modals/TransferModal/index.tsx +92 -0
- package/src/react/ui/modals/TransferModal/messages.ts +14 -0
- package/src/react/ui/modals/TransferModal/styles.css.ts +20 -0
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +94 -0
- package/src/react/ui/modals/_internal/components/actionModal/index.ts +3 -0
- package/src/react/ui/modals/_internal/components/actionModal/store.ts +19 -0
- package/src/react/ui/modals/_internal/components/actionModal/styles.css.ts +15 -0
- package/src/react/ui/modals/_internal/components/alertMessage/index.tsx +21 -0
- package/src/react/ui/modals/_internal/components/alertMessage/styles.css.ts +22 -0
- package/src/react/ui/modals/_internal/components/calendar/index.tsx +59 -0
- package/src/react/ui/modals/_internal/components/calendarPopover/index.tsx +41 -0
- package/src/react/ui/modals/_internal/components/calendarPopover/styles.css.ts +16 -0
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +76 -0
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/styles.css.ts +33 -0
- package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +127 -0
- package/src/react/ui/modals/_internal/components/expirationDateSelect/styles.css.ts +25 -0
- package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +54 -0
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +72 -0
- package/src/react/ui/modals/_internal/components/priceInput/styles.css.ts +23 -0
- package/src/react/ui/modals/_internal/components/priceInput/types.ts +4 -0
- package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +168 -0
- package/src/react/ui/modals/_internal/components/quantityInput/styles.css.ts +30 -0
- package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +132 -0
- package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +41 -0
- package/src/react/ui/modals/_internal/components/switchChainModal/styles.css.ts +37 -0
- package/src/react/ui/modals/_internal/components/timeAgo/index.tsx +32 -0
- package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +58 -0
- package/src/react/ui/modals/_internal/components/tokenPreview/styles.css.ts +11 -0
- package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +48 -0
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +80 -0
- package/src/react/ui/modals/_internal/components/transactionHeader/index.tsx +30 -0
- package/src/react/ui/modals/_internal/components/transactionPreview/consts.ts +27 -0
- package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +111 -0
- package/src/react/ui/modals/_internal/components/transactionPreview/useTransactionPreviewTitle.tsx +24 -0
- package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +123 -0
- package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +87 -0
- package/src/react/ui/modals/_internal/components/transactionStatusModal/styles.css.ts +15 -0
- package/src/react/ui/modals/_internal/stores/accountModal.ts +3 -0
- package/src/react/ui/modals/modal-provider.tsx +27 -0
- package/src/react/ui/styles/index.ts +1 -0
- package/src/react/ui/styles/modal.css.ts +73 -0
- package/src/styles/index.ts +18 -0
- package/src/types/api-types.ts +48 -0
- package/src/types/index.ts +4 -0
- package/src/types/marketplace-config.ts +63 -0
- package/src/types/messages.ts +43 -0
- package/src/types/sdk-config.ts +23 -0
- package/src/types/types.ts +6 -0
- package/src/utils/abi/abi/standard/EIP2981.ts +15 -0
- package/src/utils/abi/abi/standard/index.ts +1 -0
- package/src/utils/abi/abi/token/ERC1155.ts +324 -0
- package/src/utils/abi/abi/token/ERC20.ts +185 -0
- package/src/utils/abi/abi/token/ERC721.ts +506 -0
- package/src/utils/abi/abi/token/index.ts +3 -0
- package/src/utils/abi/clients/ERC1155.ts +82 -0
- package/src/utils/abi/clients/ERC20.ts +101 -0
- package/src/utils/abi/clients/ERC721.ts +97 -0
- package/src/utils/abi/clients/index.ts +3 -0
- package/src/utils/address.ts +26 -0
- package/src/utils/get-public-rpc-client.ts +32 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/network.ts +5 -0
- package/src/utils/price.ts +21 -0
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
export const ERC721_ABI = [
|
|
2
|
+
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
|
|
3
|
+
{ inputs: [], name: 'AlreadyInitialized', type: 'error' },
|
|
4
|
+
{ inputs: [], name: 'InvalidMintRequest', type: 'error' },
|
|
5
|
+
{ inputs: [], name: 'InvalidSequenceConfig', type: 'error' },
|
|
6
|
+
{ inputs: [], name: 'NotAuthorized', type: 'error' },
|
|
7
|
+
{ inputs: [], name: 'SequenceIsSealed', type: 'error' },
|
|
8
|
+
{ inputs: [], name: 'SequenceSupplyExhausted', type: 'error' },
|
|
9
|
+
{
|
|
10
|
+
anonymous: false,
|
|
11
|
+
inputs: [
|
|
12
|
+
{
|
|
13
|
+
indexed: true,
|
|
14
|
+
internalType: 'address',
|
|
15
|
+
name: 'owner',
|
|
16
|
+
type: 'address',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
indexed: true,
|
|
20
|
+
internalType: 'address',
|
|
21
|
+
name: 'spender',
|
|
22
|
+
type: 'address',
|
|
23
|
+
},
|
|
24
|
+
{ indexed: true, internalType: 'uint256', name: 'id', type: 'uint256' },
|
|
25
|
+
],
|
|
26
|
+
name: 'Approval',
|
|
27
|
+
type: 'event',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
anonymous: false,
|
|
31
|
+
inputs: [
|
|
32
|
+
{
|
|
33
|
+
indexed: true,
|
|
34
|
+
internalType: 'address',
|
|
35
|
+
name: 'owner',
|
|
36
|
+
type: 'address',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
indexed: true,
|
|
40
|
+
internalType: 'address',
|
|
41
|
+
name: 'operator',
|
|
42
|
+
type: 'address',
|
|
43
|
+
},
|
|
44
|
+
{ indexed: false, internalType: 'bool', name: 'approved', type: 'bool' },
|
|
45
|
+
],
|
|
46
|
+
name: 'ApprovalForAll',
|
|
47
|
+
type: 'event',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
anonymous: false,
|
|
51
|
+
inputs: [
|
|
52
|
+
{ indexed: false, internalType: 'string', name: 'topic', type: 'string' },
|
|
53
|
+
{
|
|
54
|
+
indexed: false,
|
|
55
|
+
internalType: 'string',
|
|
56
|
+
name: 'message',
|
|
57
|
+
type: 'string',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
name: 'Broadcast',
|
|
61
|
+
type: 'event',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
anonymous: false,
|
|
65
|
+
inputs: [
|
|
66
|
+
{
|
|
67
|
+
indexed: true,
|
|
68
|
+
internalType: 'address',
|
|
69
|
+
name: 'previousOwner',
|
|
70
|
+
type: 'address',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
indexed: true,
|
|
74
|
+
internalType: 'address',
|
|
75
|
+
name: 'newOwner',
|
|
76
|
+
type: 'address',
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
name: 'OwnershipTransferred',
|
|
80
|
+
type: 'event',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
anonymous: false,
|
|
84
|
+
inputs: [
|
|
85
|
+
{
|
|
86
|
+
indexed: true,
|
|
87
|
+
internalType: 'uint256',
|
|
88
|
+
name: 'tokenId',
|
|
89
|
+
type: 'uint256',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
indexed: true,
|
|
93
|
+
internalType: 'uint16',
|
|
94
|
+
name: 'sequenceId',
|
|
95
|
+
type: 'uint16',
|
|
96
|
+
},
|
|
97
|
+
{ indexed: false, internalType: 'uint80', name: 'data', type: 'uint80' },
|
|
98
|
+
],
|
|
99
|
+
name: 'RecordCreated',
|
|
100
|
+
type: 'event',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
anonymous: false,
|
|
104
|
+
inputs: [
|
|
105
|
+
{
|
|
106
|
+
indexed: true,
|
|
107
|
+
internalType: 'uint16',
|
|
108
|
+
name: 'sequenceId',
|
|
109
|
+
type: 'uint16',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
components: [
|
|
113
|
+
{
|
|
114
|
+
internalType: 'uint64',
|
|
115
|
+
name: 'sealedBeforeTimestamp',
|
|
116
|
+
type: 'uint64',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
internalType: 'uint64',
|
|
120
|
+
name: 'sealedAfterTimestamp',
|
|
121
|
+
type: 'uint64',
|
|
122
|
+
},
|
|
123
|
+
{ internalType: 'uint64', name: 'maxSupply', type: 'uint64' },
|
|
124
|
+
{ internalType: 'uint64', name: 'minted', type: 'uint64' },
|
|
125
|
+
{ internalType: 'contract IEngine', name: 'engine', type: 'address' },
|
|
126
|
+
{ internalType: 'uint64', name: 'dropNodeId', type: 'uint64' },
|
|
127
|
+
],
|
|
128
|
+
indexed: false,
|
|
129
|
+
internalType: 'struct SequenceData',
|
|
130
|
+
name: 'sequenceData',
|
|
131
|
+
type: 'tuple',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
indexed: false,
|
|
135
|
+
internalType: 'bytes',
|
|
136
|
+
name: 'engineData',
|
|
137
|
+
type: 'bytes',
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
name: 'SequenceConfigured',
|
|
141
|
+
type: 'event',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
anonymous: false,
|
|
145
|
+
inputs: [
|
|
146
|
+
{ indexed: true, internalType: 'address', name: 'from', type: 'address' },
|
|
147
|
+
{ indexed: true, internalType: 'address', name: 'to', type: 'address' },
|
|
148
|
+
{ indexed: true, internalType: 'uint256', name: 'id', type: 'uint256' },
|
|
149
|
+
],
|
|
150
|
+
name: 'Transfer',
|
|
151
|
+
type: 'event',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
inputs: [],
|
|
155
|
+
name: 'accessControl',
|
|
156
|
+
outputs: [
|
|
157
|
+
{
|
|
158
|
+
internalType: 'contract INodeRegistry',
|
|
159
|
+
name: 'nodeRegistry',
|
|
160
|
+
type: 'address',
|
|
161
|
+
},
|
|
162
|
+
{ internalType: 'uint64', name: 'controlNodeId', type: 'uint64' },
|
|
163
|
+
],
|
|
164
|
+
stateMutability: 'view',
|
|
165
|
+
type: 'function',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
inputs: [
|
|
169
|
+
{ internalType: 'address', name: 'spender', type: 'address' },
|
|
170
|
+
{ internalType: 'uint256', name: 'id', type: 'uint256' },
|
|
171
|
+
],
|
|
172
|
+
name: 'approve',
|
|
173
|
+
outputs: [],
|
|
174
|
+
stateMutability: 'nonpayable',
|
|
175
|
+
type: 'function',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
|
|
179
|
+
name: 'balanceOf',
|
|
180
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
181
|
+
stateMutability: 'view',
|
|
182
|
+
type: 'function',
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
inputs: [
|
|
186
|
+
{ internalType: 'string', name: 'topic', type: 'string' },
|
|
187
|
+
{ internalType: 'string', name: 'message', type: 'string' },
|
|
188
|
+
],
|
|
189
|
+
name: 'broadcast',
|
|
190
|
+
outputs: [],
|
|
191
|
+
stateMutability: 'nonpayable',
|
|
192
|
+
type: 'function',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
inputs: [
|
|
196
|
+
{
|
|
197
|
+
components: [
|
|
198
|
+
{
|
|
199
|
+
internalType: 'uint64',
|
|
200
|
+
name: 'sealedBeforeTimestamp',
|
|
201
|
+
type: 'uint64',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
internalType: 'uint64',
|
|
205
|
+
name: 'sealedAfterTimestamp',
|
|
206
|
+
type: 'uint64',
|
|
207
|
+
},
|
|
208
|
+
{ internalType: 'uint64', name: 'maxSupply', type: 'uint64' },
|
|
209
|
+
{ internalType: 'uint64', name: 'minted', type: 'uint64' },
|
|
210
|
+
{ internalType: 'contract IEngine', name: 'engine', type: 'address' },
|
|
211
|
+
{ internalType: 'uint64', name: 'dropNodeId', type: 'uint64' },
|
|
212
|
+
],
|
|
213
|
+
internalType: 'struct SequenceData',
|
|
214
|
+
name: '_sequence',
|
|
215
|
+
type: 'tuple',
|
|
216
|
+
},
|
|
217
|
+
{ internalType: 'bytes', name: '_engineData', type: 'bytes' },
|
|
218
|
+
],
|
|
219
|
+
name: 'configureSequence',
|
|
220
|
+
outputs: [],
|
|
221
|
+
stateMutability: 'nonpayable',
|
|
222
|
+
type: 'function',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
inputs: [],
|
|
226
|
+
name: 'contractURI',
|
|
227
|
+
outputs: [{ internalType: 'string', name: 'value', type: 'string' }],
|
|
228
|
+
stateMutability: 'view',
|
|
229
|
+
type: 'function',
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
inputs: [],
|
|
233
|
+
name: 'controlNode',
|
|
234
|
+
outputs: [{ internalType: 'uint64', name: 'nodeId', type: 'uint64' }],
|
|
235
|
+
stateMutability: 'view',
|
|
236
|
+
type: 'function',
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
240
|
+
name: 'getApproved',
|
|
241
|
+
outputs: [{ internalType: 'address', name: '', type: 'address' }],
|
|
242
|
+
stateMutability: 'view',
|
|
243
|
+
type: 'function',
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
inputs: [{ internalType: 'uint16', name: 'sequenceId', type: 'uint16' }],
|
|
247
|
+
name: 'getSequenceData',
|
|
248
|
+
outputs: [
|
|
249
|
+
{
|
|
250
|
+
components: [
|
|
251
|
+
{
|
|
252
|
+
internalType: 'uint64',
|
|
253
|
+
name: 'sealedBeforeTimestamp',
|
|
254
|
+
type: 'uint64',
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
internalType: 'uint64',
|
|
258
|
+
name: 'sealedAfterTimestamp',
|
|
259
|
+
type: 'uint64',
|
|
260
|
+
},
|
|
261
|
+
{ internalType: 'uint64', name: 'maxSupply', type: 'uint64' },
|
|
262
|
+
{ internalType: 'uint64', name: 'minted', type: 'uint64' },
|
|
263
|
+
{ internalType: 'contract IEngine', name: 'engine', type: 'address' },
|
|
264
|
+
{ internalType: 'uint64', name: 'dropNodeId', type: 'uint64' },
|
|
265
|
+
],
|
|
266
|
+
internalType: 'struct SequenceData',
|
|
267
|
+
name: 'sequence',
|
|
268
|
+
type: 'tuple',
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
stateMutability: 'view',
|
|
272
|
+
type: 'function',
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
inputs: [{ internalType: 'uint256', name: 'id', type: 'uint256' }],
|
|
276
|
+
name: 'getTokenData',
|
|
277
|
+
outputs: [
|
|
278
|
+
{
|
|
279
|
+
components: [
|
|
280
|
+
{ internalType: 'address', name: 'owner', type: 'address' },
|
|
281
|
+
{ internalType: 'uint16', name: 'sequenceId', type: 'uint16' },
|
|
282
|
+
{ internalType: 'uint80', name: 'data', type: 'uint80' },
|
|
283
|
+
],
|
|
284
|
+
internalType: 'struct TokenData',
|
|
285
|
+
name: '',
|
|
286
|
+
type: 'tuple',
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
stateMutability: 'view',
|
|
290
|
+
type: 'function',
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
inputs: [
|
|
294
|
+
{ internalType: 'address', name: '_owner', type: 'address' },
|
|
295
|
+
{
|
|
296
|
+
components: [
|
|
297
|
+
{
|
|
298
|
+
internalType: 'contract INodeRegistry',
|
|
299
|
+
name: 'nodeRegistry',
|
|
300
|
+
type: 'address',
|
|
301
|
+
},
|
|
302
|
+
{ internalType: 'uint64', name: 'controlNodeId', type: 'uint64' },
|
|
303
|
+
],
|
|
304
|
+
internalType: 'struct AccessControlData',
|
|
305
|
+
name: '_accessControl',
|
|
306
|
+
type: 'tuple',
|
|
307
|
+
},
|
|
308
|
+
{ internalType: 'string', name: '_metadata', type: 'string' },
|
|
309
|
+
{
|
|
310
|
+
components: [
|
|
311
|
+
{ internalType: 'string', name: 'name', type: 'string' },
|
|
312
|
+
{ internalType: 'string', name: 'symbol', type: 'string' },
|
|
313
|
+
{ internalType: 'string', name: 'contractURI', type: 'string' },
|
|
314
|
+
],
|
|
315
|
+
internalType: 'struct ImmutableCollectionData',
|
|
316
|
+
name: '_data',
|
|
317
|
+
type: 'tuple',
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
name: 'init',
|
|
321
|
+
outputs: [],
|
|
322
|
+
stateMutability: 'nonpayable',
|
|
323
|
+
type: 'function',
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
inputs: [
|
|
327
|
+
{ internalType: 'address', name: '', type: 'address' },
|
|
328
|
+
{ internalType: 'address', name: '', type: 'address' },
|
|
329
|
+
],
|
|
330
|
+
name: 'isApprovedForAll',
|
|
331
|
+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
|
|
332
|
+
stateMutability: 'view',
|
|
333
|
+
type: 'function',
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
inputs: [{ internalType: 'address', name: 'subject', type: 'address' }],
|
|
337
|
+
name: 'isAuthorized',
|
|
338
|
+
outputs: [{ internalType: 'bool', name: 'authorized', type: 'bool' }],
|
|
339
|
+
stateMutability: 'view',
|
|
340
|
+
type: 'function',
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
inputs: [
|
|
344
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
345
|
+
{ internalType: 'uint16', name: 'sequenceId', type: 'uint16' },
|
|
346
|
+
],
|
|
347
|
+
name: 'mintRecord',
|
|
348
|
+
outputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }],
|
|
349
|
+
stateMutability: 'nonpayable',
|
|
350
|
+
type: 'function',
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
inputs: [
|
|
354
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
355
|
+
{ internalType: 'uint16', name: 'sequenceId', type: 'uint16' },
|
|
356
|
+
{ internalType: 'uint80', name: 'tokenData', type: 'uint80' },
|
|
357
|
+
],
|
|
358
|
+
name: 'mintRecord',
|
|
359
|
+
outputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }],
|
|
360
|
+
stateMutability: 'nonpayable',
|
|
361
|
+
type: 'function',
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
inputs: [],
|
|
365
|
+
name: 'name',
|
|
366
|
+
outputs: [{ internalType: 'string', name: 'value', type: 'string' }],
|
|
367
|
+
stateMutability: 'view',
|
|
368
|
+
type: 'function',
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
inputs: [],
|
|
372
|
+
name: 'nodeRegistry',
|
|
373
|
+
outputs: [
|
|
374
|
+
{ internalType: 'contract INodeRegistry', name: '', type: 'address' },
|
|
375
|
+
],
|
|
376
|
+
stateMutability: 'view',
|
|
377
|
+
type: 'function',
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
inputs: [],
|
|
381
|
+
name: 'owner',
|
|
382
|
+
outputs: [{ internalType: 'address', name: '', type: 'address' }],
|
|
383
|
+
stateMutability: 'view',
|
|
384
|
+
type: 'function',
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
inputs: [{ internalType: 'uint256', name: 'id', type: 'uint256' }],
|
|
388
|
+
name: 'ownerOf',
|
|
389
|
+
outputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
|
|
390
|
+
stateMutability: 'view',
|
|
391
|
+
type: 'function',
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
inputs: [
|
|
395
|
+
{ internalType: 'uint256', name: 'tokenId', type: 'uint256' },
|
|
396
|
+
{ internalType: 'uint256', name: 'salePrice', type: 'uint256' },
|
|
397
|
+
],
|
|
398
|
+
name: 'royaltyInfo',
|
|
399
|
+
outputs: [
|
|
400
|
+
{ internalType: 'address', name: 'receiver', type: 'address' },
|
|
401
|
+
{ internalType: 'uint256', name: 'royaltyAmount', type: 'uint256' },
|
|
402
|
+
],
|
|
403
|
+
stateMutability: 'view',
|
|
404
|
+
type: 'function',
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
inputs: [
|
|
408
|
+
{ internalType: 'address', name: 'from', type: 'address' },
|
|
409
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
410
|
+
{ internalType: 'uint256', name: 'id', type: 'uint256' },
|
|
411
|
+
],
|
|
412
|
+
name: 'safeTransferFrom',
|
|
413
|
+
outputs: [],
|
|
414
|
+
stateMutability: 'nonpayable',
|
|
415
|
+
type: 'function',
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
inputs: [
|
|
419
|
+
{ internalType: 'address', name: 'from', type: 'address' },
|
|
420
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
421
|
+
{ internalType: 'uint256', name: 'id', type: 'uint256' },
|
|
422
|
+
{ internalType: 'bytes', name: 'data', type: 'bytes' },
|
|
423
|
+
],
|
|
424
|
+
name: 'safeTransferFrom',
|
|
425
|
+
outputs: [],
|
|
426
|
+
stateMutability: 'nonpayable',
|
|
427
|
+
type: 'function',
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
inputs: [],
|
|
431
|
+
name: 'sequenceCount',
|
|
432
|
+
outputs: [{ internalType: 'uint16', name: '', type: 'uint16' }],
|
|
433
|
+
stateMutability: 'view',
|
|
434
|
+
type: 'function',
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
inputs: [
|
|
438
|
+
{ internalType: 'address', name: 'operator', type: 'address' },
|
|
439
|
+
{ internalType: 'bool', name: 'approved', type: 'bool' },
|
|
440
|
+
],
|
|
441
|
+
name: 'setApprovalForAll',
|
|
442
|
+
outputs: [],
|
|
443
|
+
stateMutability: 'nonpayable',
|
|
444
|
+
type: 'function',
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
inputs: [{ internalType: 'address', name: '_owner', type: 'address' }],
|
|
448
|
+
name: 'setOwner',
|
|
449
|
+
outputs: [],
|
|
450
|
+
stateMutability: 'nonpayable',
|
|
451
|
+
type: 'function',
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
inputs: [{ internalType: 'bytes4', name: 'interfaceId', type: 'bytes4' }],
|
|
455
|
+
name: 'supportsInterface',
|
|
456
|
+
outputs: [{ internalType: 'bool', name: '', type: 'bool' }],
|
|
457
|
+
stateMutability: 'view',
|
|
458
|
+
type: 'function',
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
inputs: [],
|
|
462
|
+
name: 'symbol',
|
|
463
|
+
outputs: [{ internalType: 'string', name: 'value', type: 'string' }],
|
|
464
|
+
stateMutability: 'view',
|
|
465
|
+
type: 'function',
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }],
|
|
469
|
+
name: 'tokenMintData',
|
|
470
|
+
outputs: [{ internalType: 'uint80', name: 'data', type: 'uint80' }],
|
|
471
|
+
stateMutability: 'view',
|
|
472
|
+
type: 'function',
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }],
|
|
476
|
+
name: 'tokenSequenceId',
|
|
477
|
+
outputs: [{ internalType: 'uint16', name: 'sequenceId', type: 'uint16' }],
|
|
478
|
+
stateMutability: 'view',
|
|
479
|
+
type: 'function',
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
inputs: [{ internalType: 'uint256', name: 'tokenId', type: 'uint256' }],
|
|
483
|
+
name: 'tokenURI',
|
|
484
|
+
outputs: [{ internalType: 'string', name: 'uri', type: 'string' }],
|
|
485
|
+
stateMutability: 'view',
|
|
486
|
+
type: 'function',
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
inputs: [],
|
|
490
|
+
name: 'totalSupply',
|
|
491
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
492
|
+
stateMutability: 'view',
|
|
493
|
+
type: 'function',
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
inputs: [
|
|
497
|
+
{ internalType: 'address', name: 'from', type: 'address' },
|
|
498
|
+
{ internalType: 'address', name: 'to', type: 'address' },
|
|
499
|
+
{ internalType: 'uint256', name: 'id', type: 'uint256' },
|
|
500
|
+
],
|
|
501
|
+
name: 'transferFrom',
|
|
502
|
+
outputs: [],
|
|
503
|
+
stateMutability: 'nonpayable',
|
|
504
|
+
type: 'function',
|
|
505
|
+
},
|
|
506
|
+
] as const;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Hex, WalletClient } from 'viem';
|
|
2
|
+
import { encodeFunctionData, getContract } from 'viem';
|
|
3
|
+
import type { GetWalletClientData } from 'wagmi/query';
|
|
4
|
+
|
|
5
|
+
import { getPublicRpcClient } from '../../get-public-rpc-client';
|
|
6
|
+
import { ERC1155_ABI } from '../abi/token/ERC1155';
|
|
7
|
+
|
|
8
|
+
// biome-ignore lint/complexity/noStaticOnlyClass: In this case, this provide a pretty nice API
|
|
9
|
+
export class ERC1155 {
|
|
10
|
+
static setApprovalForAll = async (
|
|
11
|
+
erc1155Address: string,
|
|
12
|
+
operator: string,
|
|
13
|
+
approved: boolean,
|
|
14
|
+
signer: GetWalletClientData<any, any>,
|
|
15
|
+
): Promise<string> => {
|
|
16
|
+
const txHash = await signer.writeContract({
|
|
17
|
+
chain: signer.chain,
|
|
18
|
+
address: erc1155Address as Hex,
|
|
19
|
+
abi: ERC1155_ABI,
|
|
20
|
+
functionName: 'setApprovalForAll',
|
|
21
|
+
args: [operator as Hex, approved],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return txHash;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
static setApprovalForAll_data = (
|
|
28
|
+
operator: string,
|
|
29
|
+
approved: boolean,
|
|
30
|
+
): string => {
|
|
31
|
+
return encodeFunctionData({
|
|
32
|
+
abi: ERC1155_ABI,
|
|
33
|
+
functionName: 'setApprovalForAll',
|
|
34
|
+
args: [operator as Hex, approved],
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
static isApprovedForAll = async (
|
|
39
|
+
erc1155Address: string,
|
|
40
|
+
owner: string,
|
|
41
|
+
operator: string,
|
|
42
|
+
chainId: number,
|
|
43
|
+
) => {
|
|
44
|
+
const contract = getERC1155Contract({
|
|
45
|
+
contractAddress: erc1155Address,
|
|
46
|
+
chainId,
|
|
47
|
+
});
|
|
48
|
+
return contract.read.isApprovedForAll([owner as Hex, operator as Hex]);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
static balanceOf = async (
|
|
52
|
+
erc1155Address: string,
|
|
53
|
+
owner: string,
|
|
54
|
+
tokenId: string,
|
|
55
|
+
chainId: number,
|
|
56
|
+
): Promise<bigint> => {
|
|
57
|
+
const contract = getERC1155Contract({
|
|
58
|
+
contractAddress: erc1155Address,
|
|
59
|
+
chainId,
|
|
60
|
+
});
|
|
61
|
+
return contract.read.balanceOf([owner as Hex, BigInt(tokenId)]);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface ContractInstanceParams {
|
|
66
|
+
contractAddress: string;
|
|
67
|
+
chainId: number;
|
|
68
|
+
signer?: WalletClient;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const getERC1155Contract = (args: ContractInstanceParams) => {
|
|
72
|
+
const publicClient = getPublicRpcClient(args.chainId);
|
|
73
|
+
|
|
74
|
+
return getContract({
|
|
75
|
+
address: args.contractAddress as Hex,
|
|
76
|
+
abi: ERC1155_ABI,
|
|
77
|
+
client: {
|
|
78
|
+
public: publicClient,
|
|
79
|
+
wallet: args.signer,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Hex, WalletClient } from 'viem';
|
|
2
|
+
import { encodeFunctionData, getContract, maxUint256 } from 'viem';
|
|
3
|
+
import type { GetWalletClientData } from 'wagmi/query';
|
|
4
|
+
|
|
5
|
+
import { getPublicRpcClient } from '../../get-public-rpc-client';
|
|
6
|
+
import { ERC20_ABI } from '../abi/token/ERC20';
|
|
7
|
+
|
|
8
|
+
export class ERC20 {
|
|
9
|
+
static approve = async (
|
|
10
|
+
erc20Address: string,
|
|
11
|
+
spender: string,
|
|
12
|
+
amount: bigint,
|
|
13
|
+
signer: GetWalletClientData<any, any>,
|
|
14
|
+
): Promise<string> => {
|
|
15
|
+
const txHash = await signer.writeContract({
|
|
16
|
+
chain: signer.chain,
|
|
17
|
+
address: erc20Address as Hex,
|
|
18
|
+
abi: ERC20_ABI,
|
|
19
|
+
functionName: 'approve',
|
|
20
|
+
args: [spender as Hex, amount],
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return txHash;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
static approve_data = (spender: string, amount: bigint): string => {
|
|
27
|
+
return encodeFunctionData({
|
|
28
|
+
abi: ERC20_ABI,
|
|
29
|
+
functionName: 'approve',
|
|
30
|
+
args: [spender as Hex, amount],
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
static approveInfinite = async (
|
|
35
|
+
erc20Address: string,
|
|
36
|
+
spender: string,
|
|
37
|
+
signer: GetWalletClientData<any, any>,
|
|
38
|
+
): Promise<string> => {
|
|
39
|
+
const txHash = await signer.writeContract({
|
|
40
|
+
chain: signer.chain,
|
|
41
|
+
address: erc20Address as Hex,
|
|
42
|
+
abi: ERC20_ABI,
|
|
43
|
+
functionName: 'approve',
|
|
44
|
+
args: [spender as Hex, maxUint256],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return txHash;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
static approveInfinite_data = (spender: string): string => {
|
|
51
|
+
return encodeFunctionData({
|
|
52
|
+
abi: ERC20_ABI,
|
|
53
|
+
functionName: 'approve',
|
|
54
|
+
args: [spender as Hex, maxUint256],
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
static getAllowance = async (
|
|
59
|
+
erc20Address: string,
|
|
60
|
+
owner: string,
|
|
61
|
+
spender: string,
|
|
62
|
+
chainId: number,
|
|
63
|
+
): Promise<bigint> => {
|
|
64
|
+
const contract = getERC20Contract({
|
|
65
|
+
contractAddress: erc20Address,
|
|
66
|
+
chainId,
|
|
67
|
+
});
|
|
68
|
+
return contract.read.allowance([owner as Hex, spender as Hex]);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
static balanceOf = async (
|
|
72
|
+
erc20Address: string,
|
|
73
|
+
owner: string,
|
|
74
|
+
chainId: number,
|
|
75
|
+
): Promise<bigint> => {
|
|
76
|
+
const contract = getERC20Contract({
|
|
77
|
+
contractAddress: erc20Address,
|
|
78
|
+
chainId,
|
|
79
|
+
});
|
|
80
|
+
return contract.read.balanceOf([owner as Hex]);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface ContractInstanceParams {
|
|
85
|
+
contractAddress: string;
|
|
86
|
+
chainId: number;
|
|
87
|
+
signer?: WalletClient;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const getERC20Contract = (args: ContractInstanceParams) => {
|
|
91
|
+
const publicClient = getPublicRpcClient(args.chainId);
|
|
92
|
+
|
|
93
|
+
return getContract({
|
|
94
|
+
address: args.contractAddress as Hex,
|
|
95
|
+
abi: ERC20_ABI,
|
|
96
|
+
client: {
|
|
97
|
+
public: publicClient,
|
|
98
|
+
wallet: args.signer,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
};
|