@bosonprotocol/core-sdk 1.29.0-ludo.1 → 1.29.0
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/LICENSE +202 -0
- package/dist/cjs/accounts/handler.d.ts +63 -63
- package/dist/cjs/accounts/handler.js +129 -129
- package/dist/cjs/accounts/index.d.ts +8 -8
- package/dist/cjs/accounts/index.js +37 -37
- package/dist/cjs/accounts/interface.d.ts +38 -38
- package/dist/cjs/accounts/interface.js +130 -130
- package/dist/cjs/accounts/mixin.d.ts +222 -222
- package/dist/cjs/accounts/mixin.js +506 -506
- package/dist/cjs/accounts/subgraph.d.ts +17 -17
- package/dist/cjs/accounts/subgraph.d.ts.map +1 -1
- package/dist/cjs/accounts/subgraph.js +107 -107
- package/dist/cjs/accounts/types.d.ts +28 -28
- package/dist/cjs/accounts/types.d.ts.map +1 -1
- package/dist/cjs/accounts/types.js +8 -8
- package/dist/cjs/core-sdk.d.ts +55 -55
- package/dist/cjs/core-sdk.js +98 -98
- package/dist/cjs/disputes/handler.d.ts +71 -71
- package/dist/cjs/disputes/handler.js +127 -127
- package/dist/cjs/disputes/index.d.ts +3 -3
- package/dist/cjs/disputes/index.js +29 -29
- package/dist/cjs/disputes/interface.d.ts +28 -28
- package/dist/cjs/disputes/interface.js +72 -72
- package/dist/cjs/disputes/mixin.d.ts +117 -117
- package/dist/cjs/disputes/mixin.js +202 -202
- package/dist/cjs/disputes/subgraph.d.ts +5 -5
- package/dist/cjs/disputes/subgraph.d.ts.map +1 -1
- package/dist/cjs/disputes/subgraph.js +29 -29
- package/dist/cjs/erc1155/handler.d.ts +8 -8
- package/dist/cjs/erc1155/handler.js +27 -27
- package/dist/cjs/erc1155/index.d.ts +2 -2
- package/dist/cjs/erc1155/index.js +28 -28
- package/dist/cjs/erc1155/interface.d.ts +2 -2
- package/dist/cjs/erc1155/interface.js +6 -6
- package/dist/cjs/erc1155/mixin.d.ts +5 -5
- package/dist/cjs/erc1155/mixin.js +25 -25
- package/dist/cjs/erc20/handler.d.ts +38 -38
- package/dist/cjs/erc20/handler.js +88 -88
- package/dist/cjs/erc20/index.d.ts +3 -3
- package/dist/cjs/erc20/index.js +29 -29
- package/dist/cjs/erc20/interface.d.ts +2 -2
- package/dist/cjs/erc20/interface.js +6 -6
- package/dist/cjs/erc20/mixin.d.ts +11 -11
- package/dist/cjs/erc20/mixin.js +55 -55
- package/dist/cjs/erc20/subgraph.d.ts +4 -4
- package/dist/cjs/erc20/subgraph.d.ts.map +1 -1
- package/dist/cjs/erc20/subgraph.js +29 -29
- package/dist/cjs/erc721/handler.d.ts +18 -18
- package/dist/cjs/erc721/handler.js +50 -50
- package/dist/cjs/erc721/index.d.ts +2 -2
- package/dist/cjs/erc721/index.js +28 -28
- package/dist/cjs/erc721/interface.d.ts +2 -2
- package/dist/cjs/erc721/interface.js +6 -6
- package/dist/cjs/erc721/mixin.d.ts +7 -7
- package/dist/cjs/erc721/mixin.js +35 -35
- package/dist/cjs/event-logs/index.d.ts +1 -1
- package/dist/cjs/event-logs/index.js +27 -27
- package/dist/cjs/event-logs/mixin.d.ts +10 -10
- package/dist/cjs/event-logs/mixin.js +27 -27
- package/dist/cjs/event-logs/subgraph.d.ts +2 -2
- package/dist/cjs/event-logs/subgraph.js +21 -21
- package/dist/cjs/exchanges/getExchangeState.d.ts +8 -8
- package/dist/cjs/exchanges/getExchangeState.d.ts.map +1 -1
- package/dist/cjs/exchanges/getExchangeState.js +21 -21
- package/dist/cjs/exchanges/getExchangeState.js.map +1 -1
- package/dist/cjs/exchanges/handler.d.ts +30 -30
- package/dist/cjs/exchanges/handler.d.ts.map +1 -1
- package/dist/cjs/exchanges/handler.js +201 -201
- package/dist/cjs/exchanges/index.d.ts +4 -4
- package/dist/cjs/exchanges/index.js +33 -33
- package/dist/cjs/exchanges/interface.d.ts +10 -10
- package/dist/cjs/exchanges/interface.js +49 -49
- package/dist/cjs/exchanges/mixin.d.ts +76 -76
- package/dist/cjs/exchanges/mixin.js +171 -171
- package/dist/cjs/exchanges/subgraph.d.ts +5 -5
- package/dist/cjs/exchanges/subgraph.d.ts.map +1 -1
- package/dist/cjs/exchanges/subgraph.js +29 -29
- package/dist/cjs/forwarder/biconomy-interface.d.ts +71 -71
- package/dist/cjs/forwarder/biconomy-interface.d.ts.map +1 -1
- package/dist/cjs/forwarder/biconomy-interface.js +30 -30
- package/dist/cjs/forwarder/handler.d.ts +18 -18
- package/dist/cjs/forwarder/handler.js +76 -76
- package/dist/cjs/forwarder/index.d.ts +3 -3
- package/dist/cjs/forwarder/index.js +29 -29
- package/dist/cjs/forwarder/mock-interface.d.ts +40 -40
- package/dist/cjs/forwarder/mock-interface.d.ts.map +1 -1
- package/dist/cjs/forwarder/mock-interface.js +15 -15
- package/dist/cjs/funds/handler.d.ts +22 -22
- package/dist/cjs/funds/handler.js +64 -64
- package/dist/cjs/funds/index.d.ts +3 -3
- package/dist/cjs/funds/index.js +29 -29
- package/dist/cjs/funds/interface.d.ts +5 -5
- package/dist/cjs/funds/interface.js +22 -22
- package/dist/cjs/funds/mixin.d.ts +41 -41
- package/dist/cjs/funds/mixin.js +94 -94
- package/dist/cjs/funds/subgraph.d.ts +5 -5
- package/dist/cjs/funds/subgraph.d.ts.map +1 -1
- package/dist/cjs/funds/subgraph.js +29 -29
- package/dist/cjs/groups/handler.d.ts +6 -6
- package/dist/cjs/groups/handler.js +22 -22
- package/dist/cjs/groups/index.d.ts +3 -3
- package/dist/cjs/groups/index.js +29 -29
- package/dist/cjs/groups/interface.d.ts +5 -5
- package/dist/cjs/groups/interface.js +28 -28
- package/dist/cjs/groups/mixin.d.ts +13 -13
- package/dist/cjs/groups/mixin.js +32 -32
- package/dist/cjs/groups/subgraph.d.ts +1 -1
- package/dist/cjs/groups/subgraph.js +4 -4
- package/dist/cjs/index.d.ts +17 -17
- package/dist/cjs/index.js +51 -51
- package/dist/cjs/meta-tx/biconomy.d.ts +59 -59
- package/dist/cjs/meta-tx/biconomy.d.ts.map +1 -1
- package/dist/cjs/meta-tx/biconomy.js +107 -107
- package/dist/cjs/meta-tx/handler.d.ts +230 -230
- package/dist/cjs/meta-tx/handler.d.ts.map +1 -1
- package/dist/cjs/meta-tx/handler.js +665 -665
- package/dist/cjs/meta-tx/index.d.ts +2 -2
- package/dist/cjs/meta-tx/index.js +28 -28
- package/dist/cjs/meta-tx/interface.d.ts +2 -2
- package/dist/cjs/meta-tx/interface.js +6 -6
- package/dist/cjs/meta-tx/mixin.d.ts +219 -219
- package/dist/cjs/meta-tx/mixin.js +474 -474
- package/dist/cjs/metadata/index.d.ts +1 -1
- package/dist/cjs/metadata/index.js +27 -27
- package/dist/cjs/metadata/mixin.d.ts +41 -41
- package/dist/cjs/metadata/mixin.js +88 -88
- package/dist/cjs/metadata/subgraph.d.ts +20 -20
- package/dist/cjs/metadata/subgraph.d.ts.map +1 -1
- package/dist/cjs/metadata/subgraph.js +108 -108
- package/dist/cjs/mixins/base-core-sdk.d.ts +44 -44
- package/dist/cjs/mixins/base-core-sdk.js +52 -52
- package/dist/cjs/native-meta-tx/handler.d.ts +42 -42
- package/dist/cjs/native-meta-tx/handler.js +135 -135
- package/dist/cjs/native-meta-tx/index.d.ts +2 -2
- package/dist/cjs/native-meta-tx/index.js +28 -28
- package/dist/cjs/native-meta-tx/interface.d.ts +3 -3
- package/dist/cjs/native-meta-tx/interface.js +29 -29
- package/dist/cjs/native-meta-tx/mixin.d.ts +34 -34
- package/dist/cjs/native-meta-tx/mixin.js +67 -67
- package/dist/cjs/native-meta-tx/tokenSpecifics.d.ts +6 -6
- package/dist/cjs/native-meta-tx/tokenSpecifics.d.ts.map +1 -1
- package/dist/cjs/native-meta-tx/tokenSpecifics.js +20 -20
- package/dist/cjs/offers/checkExchangePolicy.d.ts +48 -48
- package/dist/cjs/offers/checkExchangePolicy.d.ts.map +1 -1
- package/dist/cjs/offers/checkExchangePolicy.js +24 -24
- package/dist/cjs/offers/getOfferStatus.d.ts +8 -8
- package/dist/cjs/offers/getOfferStatus.js +25 -25
- package/dist/cjs/offers/getOfferStatus.js.map +1 -1
- package/dist/cjs/offers/handler.d.ts +51 -51
- package/dist/cjs/offers/handler.js +151 -151
- package/dist/cjs/offers/index.d.ts +12 -12
- package/dist/cjs/offers/index.js +41 -41
- package/dist/cjs/offers/interface.d.ts +18 -18
- package/dist/cjs/offers/interface.js +91 -91
- package/dist/cjs/offers/mixin.d.ts +170 -170
- package/dist/cjs/offers/mixin.js +408 -408
- package/dist/cjs/offers/renderContractualAgreement.d.ts +53 -53
- package/dist/cjs/offers/renderContractualAgreement.d.ts.map +1 -1
- package/dist/cjs/offers/renderContractualAgreement.js +232 -232
- package/dist/cjs/offers/storage.d.ts +12 -12
- package/dist/cjs/offers/storage.js +29 -29
- package/dist/cjs/offers/subgraph.d.ts +5 -5
- package/dist/cjs/offers/subgraph.d.ts.map +1 -1
- package/dist/cjs/offers/subgraph.js +29 -29
- package/dist/cjs/offers/types.d.ts +1 -1
- package/dist/cjs/offers/types.js +2 -2
- package/dist/cjs/orchestration/handler.d.ts +73 -73
- package/dist/cjs/orchestration/handler.js +146 -146
- package/dist/cjs/orchestration/index.d.ts +2 -2
- package/dist/cjs/orchestration/index.js +28 -28
- package/dist/cjs/orchestration/interface.d.ts +14 -14
- package/dist/cjs/orchestration/interface.js +114 -114
- package/dist/cjs/orchestration/mixin.d.ts +84 -84
- package/dist/cjs/orchestration/mixin.js +163 -163
- package/dist/cjs/seaport/abi.d.ts +40 -40
- package/dist/cjs/seaport/abi.js +152 -152
- package/dist/cjs/seaport/handler.d.ts +45 -45
- package/dist/cjs/seaport/handler.d.ts.map +1 -1
- package/dist/cjs/seaport/handler.js +27 -27
- package/dist/cjs/seaport/handler.js.map +1 -1
- package/dist/cjs/seaport/index.d.ts +1 -1
- package/dist/cjs/seaport/index.js +27 -27
- package/dist/cjs/subgraph.d.ts +33033 -33033
- package/dist/cjs/subgraph.d.ts.map +1 -1
- package/dist/cjs/subgraph.js +854 -854
- package/dist/cjs/subgraph.js.map +1 -1
- package/dist/cjs/utils/errors.d.ts +4 -4
- package/dist/cjs/utils/errors.js +10 -10
- package/dist/cjs/utils/graphql.d.ts +315 -315
- package/dist/cjs/utils/graphql.js +10 -10
- package/dist/cjs/utils/logs.d.ts +20 -20
- package/dist/cjs/utils/logs.js +53 -53
- package/dist/cjs/utils/signature.d.ts +23 -23
- package/dist/cjs/utils/signature.d.ts.map +1 -1
- package/dist/cjs/utils/signature.js +64 -64
- package/dist/cjs/utils/tokenInfoManager.d.ts +23 -23
- package/dist/cjs/utils/tokenInfoManager.js +139 -139
- package/dist/cjs/voucher/handler.d.ts +68 -68
- package/dist/cjs/voucher/handler.js +134 -134
- package/dist/cjs/voucher/index.d.ts +2 -2
- package/dist/cjs/voucher/index.js +28 -28
- package/dist/cjs/voucher/interface.d.ts +21 -21
- package/dist/cjs/voucher/interface.js +140 -140
- package/dist/cjs/voucher/mixin.d.ts +67 -67
- package/dist/cjs/voucher/mixin.js +166 -166
- package/dist/esm/accounts/handler.d.ts +63 -63
- package/dist/esm/accounts/handler.js +91 -91
- package/dist/esm/accounts/index.d.ts +8 -8
- package/dist/esm/accounts/index.js +8 -8
- package/dist/esm/accounts/interface.d.ts +38 -38
- package/dist/esm/accounts/interface.js +111 -111
- package/dist/esm/accounts/mixin.d.ts +222 -222
- package/dist/esm/accounts/mixin.js +416 -416
- package/dist/esm/accounts/subgraph.d.ts +17 -17
- package/dist/esm/accounts/subgraph.d.ts.map +1 -1
- package/dist/esm/accounts/subgraph.js +99 -99
- package/dist/esm/accounts/types.d.ts +28 -28
- package/dist/esm/accounts/types.d.ts.map +1 -1
- package/dist/esm/accounts/types.js +1 -1
- package/dist/esm/core-sdk.d.ts +55 -55
- package/dist/esm/core-sdk.js +97 -97
- package/dist/esm/disputes/handler.d.ts +71 -71
- package/dist/esm/disputes/handler.js +82 -82
- package/dist/esm/disputes/index.d.ts +3 -3
- package/dist/esm/disputes/index.js +3 -3
- package/dist/esm/disputes/interface.d.ts +28 -28
- package/dist/esm/disputes/interface.js +59 -59
- package/dist/esm/disputes/mixin.d.ts +117 -117
- package/dist/esm/disputes/mixin.js +172 -172
- package/dist/esm/disputes/subgraph.d.ts +5 -5
- package/dist/esm/disputes/subgraph.d.ts.map +1 -1
- package/dist/esm/disputes/subgraph.js +14 -14
- package/dist/esm/erc1155/handler.d.ts +8 -8
- package/dist/esm/erc1155/handler.js +12 -12
- package/dist/esm/erc1155/index.d.ts +2 -2
- package/dist/esm/erc1155/index.js +2 -2
- package/dist/esm/erc1155/interface.d.ts +2 -2
- package/dist/esm/erc1155/interface.js +3 -3
- package/dist/esm/erc1155/mixin.d.ts +5 -5
- package/dist/esm/erc1155/mixin.js +10 -10
- package/dist/esm/erc20/handler.d.ts +38 -38
- package/dist/esm/erc20/handler.js +55 -55
- package/dist/esm/erc20/index.d.ts +3 -3
- package/dist/esm/erc20/index.js +3 -3
- package/dist/esm/erc20/interface.d.ts +2 -2
- package/dist/esm/erc20/interface.js +3 -3
- package/dist/esm/erc20/mixin.d.ts +11 -11
- package/dist/esm/erc20/mixin.js +28 -28
- package/dist/esm/erc20/subgraph.d.ts +4 -4
- package/dist/esm/erc20/subgraph.d.ts.map +1 -1
- package/dist/esm/erc20/subgraph.js +14 -14
- package/dist/esm/erc721/handler.d.ts +18 -18
- package/dist/esm/erc721/handler.js +29 -29
- package/dist/esm/erc721/index.d.ts +2 -2
- package/dist/esm/erc721/index.js +2 -2
- package/dist/esm/erc721/interface.d.ts +2 -2
- package/dist/esm/erc721/interface.js +3 -3
- package/dist/esm/erc721/mixin.d.ts +7 -7
- package/dist/esm/erc721/mixin.js +16 -16
- package/dist/esm/event-logs/index.d.ts +1 -1
- package/dist/esm/event-logs/index.js +1 -1
- package/dist/esm/event-logs/mixin.d.ts +10 -10
- package/dist/esm/event-logs/mixin.js +12 -12
- package/dist/esm/event-logs/subgraph.d.ts +2 -2
- package/dist/esm/event-logs/subgraph.js +6 -6
- package/dist/esm/exchanges/getExchangeState.d.ts +8 -8
- package/dist/esm/exchanges/getExchangeState.d.ts.map +1 -1
- package/dist/esm/exchanges/getExchangeState.js +17 -17
- package/dist/esm/exchanges/handler.d.ts +30 -30
- package/dist/esm/exchanges/handler.d.ts.map +1 -1
- package/dist/esm/exchanges/handler.js +168 -168
- package/dist/esm/exchanges/index.d.ts +4 -4
- package/dist/esm/exchanges/index.js +4 -4
- package/dist/esm/exchanges/interface.d.ts +10 -10
- package/dist/esm/exchanges/interface.js +39 -39
- package/dist/esm/exchanges/mixin.d.ts +76 -76
- package/dist/esm/exchanges/mixin.js +140 -140
- package/dist/esm/exchanges/subgraph.d.ts +5 -5
- package/dist/esm/exchanges/subgraph.d.ts.map +1 -1
- package/dist/esm/exchanges/subgraph.js +14 -14
- package/dist/esm/forwarder/biconomy-interface.d.ts +71 -71
- package/dist/esm/forwarder/biconomy-interface.d.ts.map +1 -1
- package/dist/esm/forwarder/biconomy-interface.js +23 -23
- package/dist/esm/forwarder/handler.d.ts +18 -18
- package/dist/esm/forwarder/handler.js +35 -35
- package/dist/esm/forwarder/index.d.ts +3 -3
- package/dist/esm/forwarder/index.js +3 -3
- package/dist/esm/forwarder/mock-interface.d.ts +40 -40
- package/dist/esm/forwarder/mock-interface.d.ts.map +1 -1
- package/dist/esm/forwarder/mock-interface.js +10 -10
- package/dist/esm/funds/handler.d.ts +22 -22
- package/dist/esm/funds/handler.js +43 -43
- package/dist/esm/funds/index.d.ts +3 -3
- package/dist/esm/funds/index.js +3 -3
- package/dist/esm/funds/interface.d.ts +5 -5
- package/dist/esm/funds/interface.js +17 -17
- package/dist/esm/funds/mixin.d.ts +41 -41
- package/dist/esm/funds/mixin.js +71 -71
- package/dist/esm/funds/subgraph.d.ts +5 -5
- package/dist/esm/funds/subgraph.d.ts.map +1 -1
- package/dist/esm/funds/subgraph.js +14 -14
- package/dist/esm/groups/handler.d.ts +6 -6
- package/dist/esm/groups/handler.js +7 -7
- package/dist/esm/groups/index.d.ts +3 -3
- package/dist/esm/groups/index.js +3 -3
- package/dist/esm/groups/interface.d.ts +5 -5
- package/dist/esm/groups/interface.js +23 -23
- package/dist/esm/groups/mixin.d.ts +13 -13
- package/dist/esm/groups/mixin.js +17 -17
- package/dist/esm/groups/subgraph.d.ts +1 -1
- package/dist/esm/groups/subgraph.js +1 -1
- package/dist/esm/index.d.ts +17 -17
- package/dist/esm/index.js +17 -17
- package/dist/esm/meta-tx/biconomy.d.ts +59 -59
- package/dist/esm/meta-tx/biconomy.d.ts.map +1 -1
- package/dist/esm/meta-tx/biconomy.js +89 -89
- package/dist/esm/meta-tx/handler.d.ts +230 -230
- package/dist/esm/meta-tx/handler.d.ts.map +1 -1
- package/dist/esm/meta-tx/handler.js +733 -733
- package/dist/esm/meta-tx/index.d.ts +2 -2
- package/dist/esm/meta-tx/index.js +2 -2
- package/dist/esm/meta-tx/interface.d.ts +2 -2
- package/dist/esm/meta-tx/interface.js +3 -3
- package/dist/esm/meta-tx/mixin.d.ts +219 -219
- package/dist/esm/meta-tx/mixin.js +568 -568
- package/dist/esm/metadata/index.d.ts +1 -1
- package/dist/esm/metadata/index.js +1 -1
- package/dist/esm/metadata/mixin.d.ts +41 -41
- package/dist/esm/metadata/mixin.js +59 -59
- package/dist/esm/metadata/subgraph.d.ts +20 -20
- package/dist/esm/metadata/subgraph.d.ts.map +1 -1
- package/dist/esm/metadata/subgraph.js +86 -86
- package/dist/esm/mixins/base-core-sdk.d.ts +44 -44
- package/dist/esm/mixins/base-core-sdk.js +57 -57
- package/dist/esm/native-meta-tx/handler.d.ts +42 -42
- package/dist/esm/native-meta-tx/handler.js +121 -121
- package/dist/esm/native-meta-tx/index.d.ts +2 -2
- package/dist/esm/native-meta-tx/index.js +2 -2
- package/dist/esm/native-meta-tx/interface.d.ts +3 -3
- package/dist/esm/native-meta-tx/interface.js +26 -26
- package/dist/esm/native-meta-tx/mixin.d.ts +34 -34
- package/dist/esm/native-meta-tx/mixin.js +50 -50
- package/dist/esm/native-meta-tx/tokenSpecifics.d.ts +6 -6
- package/dist/esm/native-meta-tx/tokenSpecifics.d.ts.map +1 -1
- package/dist/esm/native-meta-tx/tokenSpecifics.js +15 -15
- package/dist/esm/offers/checkExchangePolicy.d.ts +48 -48
- package/dist/esm/offers/checkExchangePolicy.d.ts.map +1 -1
- package/dist/esm/offers/checkExchangePolicy.js +19 -19
- package/dist/esm/offers/getOfferStatus.d.ts +8 -8
- package/dist/esm/offers/getOfferStatus.js +21 -21
- package/dist/esm/offers/handler.d.ts +51 -51
- package/dist/esm/offers/handler.js +118 -118
- package/dist/esm/offers/index.d.ts +12 -12
- package/dist/esm/offers/index.js +12 -12
- package/dist/esm/offers/interface.d.ts +18 -18
- package/dist/esm/offers/interface.js +75 -75
- package/dist/esm/offers/mixin.d.ts +170 -170
- package/dist/esm/offers/mixin.js +338 -338
- package/dist/esm/offers/renderContractualAgreement.d.ts +53 -53
- package/dist/esm/offers/renderContractualAgreement.d.ts.map +1 -1
- package/dist/esm/offers/renderContractualAgreement.js +208 -208
- package/dist/esm/offers/storage.d.ts +12 -12
- package/dist/esm/offers/storage.js +14 -14
- package/dist/esm/offers/subgraph.d.ts +5 -5
- package/dist/esm/offers/subgraph.d.ts.map +1 -1
- package/dist/esm/offers/subgraph.js +16 -16
- package/dist/esm/offers/types.d.ts +1 -1
- package/dist/esm/offers/types.js +1 -1
- package/dist/esm/orchestration/handler.d.ts +73 -73
- package/dist/esm/orchestration/handler.js +110 -110
- package/dist/esm/orchestration/index.d.ts +2 -2
- package/dist/esm/orchestration/index.js +2 -2
- package/dist/esm/orchestration/interface.d.ts +14 -14
- package/dist/esm/orchestration/interface.js +103 -103
- package/dist/esm/orchestration/mixin.d.ts +84 -84
- package/dist/esm/orchestration/mixin.js +136 -136
- package/dist/esm/seaport/abi.d.ts +40 -40
- package/dist/esm/seaport/abi.js +149 -149
- package/dist/esm/seaport/handler.d.ts +45 -45
- package/dist/esm/seaport/handler.d.ts.map +1 -1
- package/dist/esm/seaport/handler.js +23 -23
- package/dist/esm/seaport/index.d.ts +1 -1
- package/dist/esm/seaport/index.js +1 -1
- package/dist/esm/subgraph.d.ts +33033 -33033
- package/dist/esm/subgraph.d.ts.map +1 -1
- package/dist/esm/subgraph.js +854 -854
- package/dist/esm/utils/errors.d.ts +4 -4
- package/dist/esm/utils/errors.js +7 -7
- package/dist/esm/utils/graphql.d.ts +315 -315
- package/dist/esm/utils/graphql.js +6 -6
- package/dist/esm/utils/logs.d.ts +20 -20
- package/dist/esm/utils/logs.js +47 -47
- package/dist/esm/utils/signature.d.ts +23 -23
- package/dist/esm/utils/signature.d.ts.map +1 -1
- package/dist/esm/utils/signature.js +57 -57
- package/dist/esm/utils/tokenInfoManager.d.ts +23 -23
- package/dist/esm/utils/tokenInfoManager.js +125 -125
- package/dist/esm/voucher/handler.d.ts +68 -68
- package/dist/esm/voucher/handler.js +86 -86
- package/dist/esm/voucher/index.d.ts +2 -2
- package/dist/esm/voucher/index.js +2 -2
- package/dist/esm/voucher/interface.d.ts +21 -21
- package/dist/esm/voucher/interface.js +119 -119
- package/dist/esm/voucher/mixin.d.ts +67 -67
- package/dist/esm/voucher/mixin.js +135 -135
- package/package.json +10 -6
|
@@ -1,734 +1,734 @@
|
|
|
1
|
-
import { utils, defaultConfigs } from "@bosonprotocol/common";
|
|
2
|
-
import { storeMetadataOnTheGraph } from "../offers/storage";
|
|
3
|
-
import { BigNumber } from "@ethersproject/bignumber";
|
|
4
|
-
import { encodeCreateSeller, encodeOptInToSellerUpdate, encodeUpdateSeller } from "../accounts/interface";
|
|
5
|
-
import { bosonExchangeHandlerIface } from "../exchanges/interface";
|
|
6
|
-
import { bosonOfferHandlerIface, encodeCreateOffer, encodeCreateOfferBatch, encodeReserveRange } from "../offers/interface";
|
|
7
|
-
import { prepareDataSignatureParameters } from "../utils/signature";
|
|
8
|
-
import { Biconomy } from "./biconomy";
|
|
9
|
-
import { isAddress } from "@ethersproject/address";
|
|
10
|
-
import { AddressZero } from "@ethersproject/constants";
|
|
11
|
-
import { encodeDepositFunds, encodeWithdrawFunds } from "../funds/interface";
|
|
12
|
-
import { bosonDisputeHandlerIface } from "../disputes/interface";
|
|
13
|
-
import { encodeCreateGroup } from "../groups/interface";
|
|
14
|
-
import { encodeCreateOfferWithCondition } from "../orchestration/interface";
|
|
15
|
-
import { encodeCallExternalContract, encodePreMint, encodeSetApprovalForAll, encodeSetApprovalForAllToContract } from "../voucher/interface";
|
|
16
|
-
import { keccak256 } from "@ethersproject/keccak256";
|
|
17
|
-
import { id } from "@ethersproject/hash";
|
|
18
|
-
import { defaultAbiCoder } from "@ethersproject/abi";
|
|
19
|
-
import { getNonce, verifyEIP712 } from "../forwarder/handler";
|
|
20
|
-
import { isTrustedForwarder } from "../voucher/handler";
|
|
21
|
-
export async function signMetaTx(args) {
|
|
22
|
-
const metaTransactionType = [
|
|
23
|
-
{ name: "nonce", type: "uint256" },
|
|
24
|
-
{ name: "from", type: "address" },
|
|
25
|
-
{ name: "contractAddress", type: "address" },
|
|
26
|
-
{ name: "functionName", type: "string" },
|
|
27
|
-
{ name: "functionSignature", type: "bytes" }
|
|
28
|
-
];
|
|
29
|
-
const customSignatureType = {
|
|
30
|
-
MetaTransaction: metaTransactionType
|
|
31
|
-
};
|
|
32
|
-
const signerAddress = await args.web3Lib.getSignerAddress();
|
|
33
|
-
const message = {
|
|
34
|
-
nonce: args.nonce,
|
|
35
|
-
from: signerAddress,
|
|
36
|
-
contractAddress: args.metaTxHandlerAddress,
|
|
37
|
-
functionName: args.functionName,
|
|
38
|
-
functionSignature: args.functionSignature
|
|
39
|
-
};
|
|
40
|
-
const signature = await prepareDataSignatureParameters({
|
|
41
|
-
...args,
|
|
42
|
-
verifyingContractAddress: args.metaTxHandlerAddress,
|
|
43
|
-
customSignatureType,
|
|
44
|
-
primaryType: "MetaTransaction",
|
|
45
|
-
message
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
functionName: args.functionName,
|
|
49
|
-
functionSignature: args.functionSignature,
|
|
50
|
-
...signature
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export async function signVoucherMetaTx(args) {
|
|
54
|
-
const forwardType = [
|
|
55
|
-
{ name: "from", type: "address" },
|
|
56
|
-
{ name: "to", type: "address" },
|
|
57
|
-
{ name: "nonce", type: "uint256" },
|
|
58
|
-
{ name: "data", type: "bytes" }
|
|
59
|
-
];
|
|
60
|
-
const customSignatureType = {
|
|
61
|
-
EIP712Domain: [
|
|
62
|
-
{ name: "name", type: "string" },
|
|
63
|
-
{ name: "version", type: "string" },
|
|
64
|
-
{ name: "chainId", type: "uint256" },
|
|
65
|
-
{ name: "verifyingContract", type: "address" }
|
|
66
|
-
],
|
|
67
|
-
ForwardRequest: forwardType
|
|
68
|
-
};
|
|
69
|
-
const signerAddress = await args.web3Lib.getSignerAddress();
|
|
70
|
-
const chainId = await args.web3Lib.getChainId();
|
|
71
|
-
const nonce = await getNonce({
|
|
72
|
-
contractAddress: args.forwarderAddress,
|
|
73
|
-
user: signerAddress,
|
|
74
|
-
web3Lib: args.web3Lib,
|
|
75
|
-
forwarderAbi: args.forwarderAbi
|
|
76
|
-
});
|
|
77
|
-
const message = {
|
|
78
|
-
from: signerAddress,
|
|
79
|
-
to: args.bosonVoucherAddress,
|
|
80
|
-
nonce,
|
|
81
|
-
data: args.functionSignature
|
|
82
|
-
};
|
|
83
|
-
const signature = await prepareDataSignatureParameters({
|
|
84
|
-
...args,
|
|
85
|
-
verifyingContractAddress: args.forwarderAddress,
|
|
86
|
-
customSignatureType,
|
|
87
|
-
primaryType: "ForwardRequest",
|
|
88
|
-
message,
|
|
89
|
-
customDomainData: {
|
|
90
|
-
name: "MockForwarder",
|
|
91
|
-
version: "0.0.1",
|
|
92
|
-
chainId,
|
|
93
|
-
salt: undefined
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
return {
|
|
97
|
-
to: message.to,
|
|
98
|
-
functionSignature: args.functionSignature,
|
|
99
|
-
request: message,
|
|
100
|
-
...signature
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
export async function signBiconomyVoucherMetaTx(args) {
|
|
104
|
-
const customSignatureType = {
|
|
105
|
-
EIP712Domain: [
|
|
106
|
-
{ name: "name", type: "string" },
|
|
107
|
-
{ name: "version", type: "string" },
|
|
108
|
-
// { name: "chainId", type: "uint256" },
|
|
109
|
-
// { name: "verifyingContract", type: "address" }
|
|
110
|
-
{ name: "verifyingContract", type: "address" },
|
|
111
|
-
{ name: "salt", type: "bytes32" }
|
|
112
|
-
],
|
|
113
|
-
ERC20ForwardRequest: [
|
|
114
|
-
{ name: "from", type: "address" },
|
|
115
|
-
{ name: "to", type: "address" },
|
|
116
|
-
{ name: "token", type: "address" },
|
|
117
|
-
{ name: "txGas", type: "uint256" },
|
|
118
|
-
{ name: "tokenGasPrice", type: "uint256" },
|
|
119
|
-
{ name: "batchId", type: "uint256" },
|
|
120
|
-
{ name: "batchNonce", type: "uint256" },
|
|
121
|
-
{ name: "deadline", type: "uint256" },
|
|
122
|
-
{ name: "data", type: "bytes" }
|
|
123
|
-
]
|
|
124
|
-
};
|
|
125
|
-
const signerAddress = await args.web3Lib.getSignerAddress();
|
|
126
|
-
const chainId = await args.web3Lib.getChainId();
|
|
127
|
-
// Check which forwarder needs to be used for the contract
|
|
128
|
-
const biconomyForwarderDomainDetails = await new Biconomy(args.relayerUrl).getForwarderDomainDetails({ chainId });
|
|
129
|
-
const biconomyForwarderDomainData = await new Promise(async (resolve, reject) => {
|
|
130
|
-
try {
|
|
131
|
-
for (const bFDD of Object.values(biconomyForwarderDomainDetails)) {
|
|
132
|
-
const ret = await isTrustedForwarder({
|
|
133
|
-
forwarder: bFDD.verifyingContract,
|
|
134
|
-
contractAddress: args.bosonVoucherAddress,
|
|
135
|
-
web3Lib: args.web3Lib
|
|
136
|
-
});
|
|
137
|
-
if (ret) {
|
|
138
|
-
resolve(bFDD);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
resolve(undefined);
|
|
142
|
-
}
|
|
143
|
-
catch (e) {
|
|
144
|
-
reject(e);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
if (!biconomyForwarderDomainData) {
|
|
148
|
-
throw `Unable to find the trusted forwarder for BosonVoucher contract ${args.bosonVoucherAddress}`;
|
|
149
|
-
}
|
|
150
|
-
const nonce = await getNonce({
|
|
151
|
-
contractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
152
|
-
user: signerAddress,
|
|
153
|
-
web3Lib: args.web3Lib,
|
|
154
|
-
batchId: args.batchId,
|
|
155
|
-
forwarderAbi: args.forwarderAbi
|
|
156
|
-
});
|
|
157
|
-
const message = {
|
|
158
|
-
from: signerAddress,
|
|
159
|
-
to: args.bosonVoucherAddress,
|
|
160
|
-
token: "0x0000000000000000000000000000000000000000",
|
|
161
|
-
txGas: args.txGas,
|
|
162
|
-
tokenGasPrice: "0",
|
|
163
|
-
batchId: args.batchId,
|
|
164
|
-
batchNonce: nonce,
|
|
165
|
-
deadline: Math.floor(Date.now() / 1000 + 3600),
|
|
166
|
-
data: args.functionSignature
|
|
167
|
-
};
|
|
168
|
-
const signatureParams = await prepareDataSignatureParameters({
|
|
169
|
-
...args,
|
|
170
|
-
chainId,
|
|
171
|
-
verifyingContractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
172
|
-
customSignatureType,
|
|
173
|
-
primaryType: "ERC20ForwardRequest",
|
|
174
|
-
message,
|
|
175
|
-
customDomainData: {
|
|
176
|
-
...biconomyForwarderDomainData
|
|
177
|
-
// chainId
|
|
178
|
-
// salt: undefined
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
const signature = signatureParams.signature;
|
|
182
|
-
const getDomainSeparator = async () => {
|
|
183
|
-
const domainData = biconomyForwarderDomainData;
|
|
184
|
-
const domainSeparator = keccak256(defaultAbiCoder.encode(["bytes32", "bytes32", "bytes32", "address", "bytes32"], [
|
|
185
|
-
id("EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)"),
|
|
186
|
-
id(domainData.name),
|
|
187
|
-
id(domainData.version),
|
|
188
|
-
domainData.verifyingContract,
|
|
189
|
-
domainData.salt
|
|
190
|
-
]));
|
|
191
|
-
return domainSeparator;
|
|
192
|
-
};
|
|
193
|
-
const domainSeparator = await getDomainSeparator();
|
|
194
|
-
// verify signature
|
|
195
|
-
const signatureVerified = await verifyEIP712({
|
|
196
|
-
request: message,
|
|
197
|
-
contractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
198
|
-
web3Lib: args.web3Lib,
|
|
199
|
-
domainSeparator,
|
|
200
|
-
forwarderAbi: args.forwarderAbi,
|
|
201
|
-
signature
|
|
202
|
-
});
|
|
203
|
-
if (!signatureVerified) {
|
|
204
|
-
throw `Signature is not verified`;
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
to: message.to,
|
|
208
|
-
domainSeparator,
|
|
209
|
-
request: message,
|
|
210
|
-
...signatureParams,
|
|
211
|
-
signature,
|
|
212
|
-
functionSignature: args.functionSignature
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
export async function relayBiconomyMetaTransaction(args) {
|
|
216
|
-
const { chainId, contractAddress, metaTx } = args;
|
|
217
|
-
const biconomy = new Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
218
|
-
const relayTxResponse = await biconomy.relayTransaction({
|
|
219
|
-
to: contractAddress,
|
|
220
|
-
params: [
|
|
221
|
-
metaTx.params.request,
|
|
222
|
-
metaTx.params.domainSeparator,
|
|
223
|
-
metaTx.params.signature
|
|
224
|
-
],
|
|
225
|
-
from: metaTx.params.userAddress,
|
|
226
|
-
signatureType: "EIP712_SIGN"
|
|
227
|
-
});
|
|
228
|
-
return {
|
|
229
|
-
wait: async () => {
|
|
230
|
-
const waitResponse = await biconomy.wait({
|
|
231
|
-
networkId: chainId,
|
|
232
|
-
transactionHash: relayTxResponse.txHash
|
|
233
|
-
});
|
|
234
|
-
const txHash = waitResponse.data.newHash;
|
|
235
|
-
const txReceipt = await args.web3LibAdapter.getTransactionReceipt(txHash);
|
|
236
|
-
return {
|
|
237
|
-
to: txReceipt?.to || contractAddress,
|
|
238
|
-
from: txReceipt?.from || metaTx.params.userAddress,
|
|
239
|
-
transactionHash: txHash,
|
|
240
|
-
logs: txReceipt?.logs || [],
|
|
241
|
-
effectiveGasPrice: BigNumber.from(waitResponse.data.newGasPrice)
|
|
242
|
-
};
|
|
243
|
-
},
|
|
244
|
-
hash: relayTxResponse.txHash
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
export async function signMetaTxCreateSeller(args) {
|
|
248
|
-
await storeMetadataOnTheGraph({
|
|
249
|
-
metadataUriOrHash: args.createSellerArgs.metadataUri,
|
|
250
|
-
metadataStorage: args.metadataStorage,
|
|
251
|
-
theGraphStorage: args.theGraphStorage
|
|
252
|
-
});
|
|
253
|
-
return signMetaTx({
|
|
254
|
-
...args,
|
|
255
|
-
functionName: "createSeller((uint256,address,address,address,address,bool,string),(uint256,uint8),(string,uint256))",
|
|
256
|
-
functionSignature: encodeCreateSeller(args.createSellerArgs)
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
export async function signMetaTxUpdateSeller(args) {
|
|
260
|
-
await storeMetadataOnTheGraph({
|
|
261
|
-
metadataUriOrHash: args.updateSellerArgs.metadataUri,
|
|
262
|
-
metadataStorage: args.metadataStorage,
|
|
263
|
-
theGraphStorage: args.theGraphStorage
|
|
264
|
-
});
|
|
265
|
-
return signMetaTx({
|
|
266
|
-
...args,
|
|
267
|
-
functionName: "updateSeller((uint256,address,address,address,address,bool,string),(uint256,uint8))",
|
|
268
|
-
functionSignature: encodeUpdateSeller(args.updateSellerArgs)
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
export async function signMetaTxOptInToSellerUpdate(args) {
|
|
272
|
-
return signMetaTx({
|
|
273
|
-
...args,
|
|
274
|
-
functionName: "optInToSellerUpdate(uint256,uint8[])",
|
|
275
|
-
functionSignature: encodeOptInToSellerUpdate(args.optInToSellerUpdateArgs)
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
export async function signMetaTxCreateOffer(args) {
|
|
279
|
-
utils.validation.createOfferArgsSchema.validateSync(args.createOfferArgs, {
|
|
280
|
-
abortEarly: false
|
|
281
|
-
});
|
|
282
|
-
await storeMetadataOnTheGraph({
|
|
283
|
-
metadataUriOrHash: args.createOfferArgs.metadataUri,
|
|
284
|
-
metadataStorage: args.metadataStorage,
|
|
285
|
-
theGraphStorage: args.theGraphStorage
|
|
286
|
-
});
|
|
287
|
-
return signMetaTx({
|
|
288
|
-
...args,
|
|
289
|
-
functionName: "createOffer((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,uint256)",
|
|
290
|
-
functionSignature: encodeCreateOffer(args.createOfferArgs)
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
export async function signMetaTxCreateOfferBatch(args) {
|
|
294
|
-
for (const offerToCreate of args.createOffersArgs) {
|
|
295
|
-
utils.validation.createOfferArgsSchema.validateSync(offerToCreate, {
|
|
296
|
-
abortEarly: false
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
await Promise.all(args.createOffersArgs.map((offerToCreate) => storeMetadataOnTheGraph({
|
|
300
|
-
metadataUriOrHash: offerToCreate.metadataUri,
|
|
301
|
-
metadataStorage: args.metadataStorage,
|
|
302
|
-
theGraphStorage: args.theGraphStorage
|
|
303
|
-
})));
|
|
304
|
-
return signMetaTx({
|
|
305
|
-
...args,
|
|
306
|
-
functionName: "createOfferBatch((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool)[],(uint256,uint256,uint256,uint256)[],(uint256,uint256,uint256)[],uint256[],uint256[])",
|
|
307
|
-
functionSignature: encodeCreateOfferBatch(args.createOffersArgs)
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
export async function signMetaTxVoidOffer(args) {
|
|
311
|
-
return signMetaTx({
|
|
312
|
-
...args,
|
|
313
|
-
functionName: "voidOffer(uint256)",
|
|
314
|
-
functionSignature: bosonOfferHandlerIface.encodeFunctionData("voidOffer", [
|
|
315
|
-
args.offerId
|
|
316
|
-
])
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
export async function signMetaTxVoidOfferBatch(args) {
|
|
320
|
-
return signMetaTx({
|
|
321
|
-
...args,
|
|
322
|
-
functionName: "voidOfferBatch(uint256[])",
|
|
323
|
-
functionSignature: bosonOfferHandlerIface.encodeFunctionData("voidOfferBatch", [args.offerIds])
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
export async function signMetaTxExtendOffer(args) {
|
|
327
|
-
return signMetaTx({
|
|
328
|
-
...args,
|
|
329
|
-
functionName: "extendOffer(uint256,uint256)",
|
|
330
|
-
functionSignature: bosonOfferHandlerIface.encodeFunctionData("extendOffer", [args.offerId, args.validUntil])
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
export async function signMetaTxExtendOfferBatch(args) {
|
|
334
|
-
return signMetaTx({
|
|
335
|
-
...args,
|
|
336
|
-
functionName: "extendOfferBatch(uint256[],uint256)",
|
|
337
|
-
functionSignature: bosonOfferHandlerIface.encodeFunctionData("extendOfferBatch", [args.offerIds, args.validUntil])
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
export async function signMetaTxCompleteExchangeBatch(args) {
|
|
341
|
-
return signMetaTx({
|
|
342
|
-
...args,
|
|
343
|
-
functionName: "completeExchangeBatch(uint256[])",
|
|
344
|
-
functionSignature: bosonExchangeHandlerIface.encodeFunctionData("completeExchangeBatch", [args.exchangeIds])
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
export async function signMetaTxExpireVoucher(args) {
|
|
348
|
-
return signMetaTx({
|
|
349
|
-
...args,
|
|
350
|
-
functionName: "expireVoucher(uint256)",
|
|
351
|
-
functionSignature: bosonExchangeHandlerIface.encodeFunctionData("expireVoucher", [args.exchangeId])
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
export async function signMetaTxRevokeVoucher(args) {
|
|
355
|
-
return signMetaTx({
|
|
356
|
-
...args,
|
|
357
|
-
functionName: "revokeVoucher(uint256)",
|
|
358
|
-
functionSignature: bosonExchangeHandlerIface.encodeFunctionData("revokeVoucher", [args.exchangeId])
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
export async function signMetaTxCreateGroup(args) {
|
|
362
|
-
return signMetaTx({
|
|
363
|
-
...args,
|
|
364
|
-
functionName: "createGroup((uint256,uint256,uint256[]),(uint8,uint8,address,uint256,uint256,uint256))",
|
|
365
|
-
functionSignature: encodeCreateGroup(args.createGroupArgs)
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
export async function signMetaTxReserveRange(args) {
|
|
369
|
-
return signMetaTx({
|
|
370
|
-
...args,
|
|
371
|
-
functionName: "reserveRange(uint256,uint256,address)",
|
|
372
|
-
functionSignature: encodeReserveRange(args.offerId, args.length, args.to)
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
export async function signMetaTxPreMint(args) {
|
|
376
|
-
const localConfig = defaultConfigs.find((config) => config.envName === "local");
|
|
377
|
-
const isLocal = localConfig.chainId === args.chainId;
|
|
378
|
-
const functionSignature = encodePreMint(args.offerId, args.amount);
|
|
379
|
-
if (isLocal) {
|
|
380
|
-
return signVoucherMetaTx({
|
|
381
|
-
...args,
|
|
382
|
-
forwarderAddress: args.forwarderAddress,
|
|
383
|
-
functionSignature,
|
|
384
|
-
forwarderAbi: args.forwarderAbi
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
const txGas = 200000 + BigNumber.from(args.amount).mul(2500).toNumber(); // ~(180000 + 2250*N) estimation on 2023/02/03
|
|
388
|
-
return signBiconomyVoucherMetaTx({
|
|
389
|
-
...args,
|
|
390
|
-
functionSignature,
|
|
391
|
-
forwarderAbi: args.forwarderAbi,
|
|
392
|
-
batchId: args.batchId || "0",
|
|
393
|
-
txGas
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
export async function signMetaTxSetApprovalForAll(args) {
|
|
397
|
-
const localConfig = defaultConfigs.find((config) => config.envName === "local");
|
|
398
|
-
const isLocal = localConfig.chainId === args.chainId;
|
|
399
|
-
const functionSignature = encodeSetApprovalForAll(args.operator, args.approved);
|
|
400
|
-
if (isLocal) {
|
|
401
|
-
return signVoucherMetaTx({
|
|
402
|
-
...args,
|
|
403
|
-
forwarderAddress: args.forwarderAddress,
|
|
404
|
-
functionSignature,
|
|
405
|
-
forwarderAbi: args.forwarderAbi
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
const txGas = 100000; // ~70000 estimation on 2023/02/03
|
|
409
|
-
return signBiconomyVoucherMetaTx({
|
|
410
|
-
...args,
|
|
411
|
-
functionSignature,
|
|
412
|
-
forwarderAbi: args.forwarderAbi,
|
|
413
|
-
batchId: args.batchId || "0",
|
|
414
|
-
txGas
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
export async function signMetaTxSetApprovalForAllToContract(args, overrides = {}) {
|
|
418
|
-
const localConfig = defaultConfigs.find((config) => config.envName === "local");
|
|
419
|
-
const isLocal = localConfig.chainId === args.chainId;
|
|
420
|
-
const functionSignature = encodeSetApprovalForAllToContract(args.operator, args.approved);
|
|
421
|
-
if (isLocal) {
|
|
422
|
-
return signVoucherMetaTx({
|
|
423
|
-
...args,
|
|
424
|
-
forwarderAddress: args.forwarderAddress,
|
|
425
|
-
functionSignature,
|
|
426
|
-
forwarderAbi: args.forwarderAbi
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
const txGas = overrides.txGas || 100000; // TODO: estimate the gas needed
|
|
430
|
-
return signBiconomyVoucherMetaTx({
|
|
431
|
-
...args,
|
|
432
|
-
functionSignature,
|
|
433
|
-
forwarderAbi: args.forwarderAbi,
|
|
434
|
-
batchId: args.batchId || "0",
|
|
435
|
-
txGas
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
export async function signMetaTxCallExternalContract(args, overrides = {}) {
|
|
439
|
-
const localConfig = defaultConfigs.find((config) => config.envName === "local");
|
|
440
|
-
const isLocal = localConfig.chainId === args.chainId;
|
|
441
|
-
const functionSignature = encodeCallExternalContract(args.to, args.data);
|
|
442
|
-
if (isLocal) {
|
|
443
|
-
return signVoucherMetaTx({
|
|
444
|
-
...args,
|
|
445
|
-
forwarderAddress: args.forwarderAddress,
|
|
446
|
-
functionSignature,
|
|
447
|
-
forwarderAbi: args.forwarderAbi
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
const txGas = overrides.txGas || 500000; // TODO: estimate the gas needed
|
|
451
|
-
return signBiconomyVoucherMetaTx({
|
|
452
|
-
...args,
|
|
453
|
-
functionSignature,
|
|
454
|
-
forwarderAbi: args.forwarderAbi,
|
|
455
|
-
batchId: args.batchId || "0",
|
|
456
|
-
txGas
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
export async function signMetaTxCreateOfferWithCondition(args) {
|
|
460
|
-
utils.validation.createOfferArgsSchema.validateSync(args.offerToCreate, {
|
|
461
|
-
abortEarly: false
|
|
462
|
-
});
|
|
463
|
-
await storeMetadataOnTheGraph({
|
|
464
|
-
metadataUriOrHash: args.offerToCreate.metadataUri,
|
|
465
|
-
metadataStorage: args.metadataStorage,
|
|
466
|
-
theGraphStorage: args.theGraphStorage
|
|
467
|
-
});
|
|
468
|
-
return signMetaTx({
|
|
469
|
-
...args,
|
|
470
|
-
functionName: "createOfferWithCondition((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,(uint8,uint8,address,uint256,uint256,uint256),uint256)",
|
|
471
|
-
functionSignature: encodeCreateOfferWithCondition(args.offerToCreate, args.condition)
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
export async function signMetaTxCommitToOffer(args) {
|
|
475
|
-
const functionName = "commitToOffer(address,uint256)";
|
|
476
|
-
const offerType = [
|
|
477
|
-
{ name: "buyer", type: "address" },
|
|
478
|
-
{ name: "offerId", type: "uint256" }
|
|
479
|
-
];
|
|
480
|
-
const metaTransactionType = [
|
|
481
|
-
{ name: "nonce", type: "uint256" },
|
|
482
|
-
{ name: "from", type: "address" },
|
|
483
|
-
{ name: "contractAddress", type: "address" },
|
|
484
|
-
{ name: "functionName", type: "string" },
|
|
485
|
-
{ name: "offerDetails", type: "MetaTxOfferDetails" }
|
|
486
|
-
];
|
|
487
|
-
const customSignatureType = {
|
|
488
|
-
MetaTxCommitToOffer: metaTransactionType,
|
|
489
|
-
MetaTxOfferDetails: offerType
|
|
490
|
-
};
|
|
491
|
-
const buyerAddress = await args.web3Lib.getSignerAddress();
|
|
492
|
-
const message = {
|
|
493
|
-
nonce: args.nonce.toString(),
|
|
494
|
-
from: buyerAddress,
|
|
495
|
-
contractAddress: args.metaTxHandlerAddress,
|
|
496
|
-
functionName,
|
|
497
|
-
offerDetails: {
|
|
498
|
-
buyer: buyerAddress,
|
|
499
|
-
offerId: args.offerId.toString()
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
const signatureParams = await prepareDataSignatureParameters({
|
|
503
|
-
...args,
|
|
504
|
-
verifyingContractAddress: args.metaTxHandlerAddress,
|
|
505
|
-
customSignatureType,
|
|
506
|
-
primaryType: "MetaTxCommitToOffer",
|
|
507
|
-
message
|
|
508
|
-
});
|
|
509
|
-
return {
|
|
510
|
-
...signatureParams,
|
|
511
|
-
functionName,
|
|
512
|
-
functionSignature: bosonExchangeHandlerIface.encodeFunctionData("commitToOffer", [buyerAddress, args.offerId])
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
export async function signMetaTxCancelVoucher(args) {
|
|
516
|
-
return makeExchangeMetaTxSigner("cancelVoucher(uint256)")(args);
|
|
517
|
-
}
|
|
518
|
-
export async function signMetaTxRedeemVoucher(args) {
|
|
519
|
-
return makeExchangeMetaTxSigner("redeemVoucher(uint256)")(args);
|
|
520
|
-
}
|
|
521
|
-
export async function signMetaTxCompleteExchange(args) {
|
|
522
|
-
return makeExchangeMetaTxSigner("completeExchange(uint256)")(args);
|
|
523
|
-
}
|
|
524
|
-
export async function signMetaTxRetractDispute(args) {
|
|
525
|
-
return makeExchangeMetaTxSigner("retractDispute(uint256)", bosonDisputeHandlerIface)(args);
|
|
526
|
-
}
|
|
527
|
-
export async function signMetaTxEscalateDispute(args) {
|
|
528
|
-
return makeExchangeMetaTxSigner("escalateDispute(uint256)", bosonDisputeHandlerIface)(args);
|
|
529
|
-
}
|
|
530
|
-
export async function signMetaTxRaiseDispute(args) {
|
|
531
|
-
return makeExchangeMetaTxSigner("raiseDispute(uint256)", bosonDisputeHandlerIface)(args);
|
|
532
|
-
}
|
|
533
|
-
export async function signMetaTxResolveDispute(args) {
|
|
534
|
-
const functionName = "resolveDispute(uint256,uint256,bytes32,bytes32,uint8)";
|
|
535
|
-
const disputeResolutionType = [
|
|
536
|
-
{ name: "exchangeId", type: "uint256" },
|
|
537
|
-
{ name: "buyerPercentBasisPoints", type: "uint256" },
|
|
538
|
-
{ name: "sigR", type: "bytes32" },
|
|
539
|
-
{ name: "sigS", type: "bytes32" },
|
|
540
|
-
{ name: "sigV", type: "uint8" }
|
|
541
|
-
];
|
|
542
|
-
const metaTransactionType = [
|
|
543
|
-
{ name: "nonce", type: "uint256" },
|
|
544
|
-
{ name: "from", type: "address" },
|
|
545
|
-
{ name: "contractAddress", type: "address" },
|
|
546
|
-
{ name: "functionName", type: "string" },
|
|
547
|
-
{ name: "disputeResolutionDetails", type: "MetaTxDisputeResolutionDetails" }
|
|
548
|
-
];
|
|
549
|
-
const customSignatureType = {
|
|
550
|
-
MetaTxDisputeResolution: metaTransactionType,
|
|
551
|
-
MetaTxDisputeResolutionDetails: disputeResolutionType
|
|
552
|
-
};
|
|
553
|
-
const message = {
|
|
554
|
-
nonce: args.nonce.toString(),
|
|
555
|
-
from: await args.web3Lib.getSignerAddress(),
|
|
556
|
-
contractAddress: args.metaTxHandlerAddress,
|
|
557
|
-
functionName,
|
|
558
|
-
disputeResolutionDetails: {
|
|
559
|
-
exchangeId: args.exchangeId.toString(),
|
|
560
|
-
buyerPercentBasisPoints: args.buyerPercent.toString(),
|
|
561
|
-
sigR: args.counterpartySig.r,
|
|
562
|
-
sigS: args.counterpartySig.s,
|
|
563
|
-
sigV: args.counterpartySig.v
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
const signatureParams = await prepareDataSignatureParameters({
|
|
567
|
-
...args,
|
|
568
|
-
verifyingContractAddress: args.metaTxHandlerAddress,
|
|
569
|
-
customSignatureType,
|
|
570
|
-
primaryType: "MetaTxDisputeResolution",
|
|
571
|
-
message
|
|
572
|
-
});
|
|
573
|
-
return {
|
|
574
|
-
...signatureParams,
|
|
575
|
-
functionName,
|
|
576
|
-
functionSignature: bosonDisputeHandlerIface.encodeFunctionData(
|
|
577
|
-
// remove params in brackets from string
|
|
578
|
-
functionName.replace(/\(([^)]*)\)[^(]*$/, ""), [
|
|
579
|
-
args.exchangeId,
|
|
580
|
-
args.buyerPercent,
|
|
581
|
-
args.counterpartySig.r,
|
|
582
|
-
args.counterpartySig.s,
|
|
583
|
-
args.counterpartySig.v
|
|
584
|
-
])
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
export async function signMetaTxExtendDisputeTimeout(args) {
|
|
588
|
-
return signMetaTx({
|
|
589
|
-
...args,
|
|
590
|
-
functionName: "extendDisputeTimeout(uint256,uint256)",
|
|
591
|
-
functionSignature: bosonDisputeHandlerIface.encodeFunctionData("extendDisputeTimeout", [args.exchangeId, args.newTimeout])
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
export async function signMetaTxWithdrawFunds(args) {
|
|
595
|
-
const functionName = "withdrawFunds(uint256,address[],uint256[])";
|
|
596
|
-
const fundType = [
|
|
597
|
-
{ name: "entityId", type: "uint256" },
|
|
598
|
-
{ name: "tokenList", type: "address[]" },
|
|
599
|
-
{ name: "tokenAmounts", type: "uint256[]" }
|
|
600
|
-
];
|
|
601
|
-
const metaTransactionType = [
|
|
602
|
-
{ name: "nonce", type: "uint256" },
|
|
603
|
-
{ name: "from", type: "address" },
|
|
604
|
-
{ name: "contractAddress", type: "address" },
|
|
605
|
-
{ name: "functionName", type: "string" },
|
|
606
|
-
{ name: "fundDetails", type: "MetaTxFundDetails" }
|
|
607
|
-
];
|
|
608
|
-
const customSignatureType = {
|
|
609
|
-
MetaTxFund: metaTransactionType,
|
|
610
|
-
MetaTxFundDetails: fundType
|
|
611
|
-
};
|
|
612
|
-
const message = {
|
|
613
|
-
nonce: args.nonce.toString(),
|
|
614
|
-
from: await args.web3Lib.getSignerAddress(),
|
|
615
|
-
contractAddress: args.metaTxHandlerAddress,
|
|
616
|
-
functionName,
|
|
617
|
-
fundDetails: {
|
|
618
|
-
entityId: args.entityId.toString(),
|
|
619
|
-
tokenList: args.tokenList,
|
|
620
|
-
tokenAmounts: args.tokenAmounts.map((bn) => bn.toString())
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
const signatureParams = await prepareDataSignatureParameters({
|
|
624
|
-
...args,
|
|
625
|
-
verifyingContractAddress: args.metaTxHandlerAddress,
|
|
626
|
-
customSignatureType,
|
|
627
|
-
primaryType: "MetaTxFund",
|
|
628
|
-
message
|
|
629
|
-
});
|
|
630
|
-
return {
|
|
631
|
-
...signatureParams,
|
|
632
|
-
functionName,
|
|
633
|
-
functionSignature: encodeWithdrawFunds(args.entityId, args.tokenList, args.tokenAmounts)
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
export async function signMetaTxDepositFunds(args) {
|
|
637
|
-
if (!isAddress(args.fundsTokenAddress)) {
|
|
638
|
-
throw new Error(`Invalid fundsTokenAddress: ${args.fundsTokenAddress}`);
|
|
639
|
-
}
|
|
640
|
-
if (args.fundsTokenAddress === AddressZero) {
|
|
641
|
-
throw new Error(`Meta transaction can't be used to deposit native currency`);
|
|
642
|
-
}
|
|
643
|
-
return signMetaTx({
|
|
644
|
-
...args,
|
|
645
|
-
functionName: "depositFunds(uint256,address,uint256)",
|
|
646
|
-
functionSignature: encodeDepositFunds(args.sellerId, args.fundsTokenAddress, args.fundsAmount)
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
function makeExchangeMetaTxSigner(functionName, handlerIface = bosonExchangeHandlerIface) {
|
|
650
|
-
return async function signExchangeMetaTx(args) {
|
|
651
|
-
const exchangeType = [{ name: "exchangeId", type: "uint256" }];
|
|
652
|
-
const metaTransactionType = [
|
|
653
|
-
{ name: "nonce", type: "uint256" },
|
|
654
|
-
{ name: "from", type: "address" },
|
|
655
|
-
{ name: "contractAddress", type: "address" },
|
|
656
|
-
{ name: "functionName", type: "string" },
|
|
657
|
-
{ name: "exchangeDetails", type: "MetaTxExchangeDetails" }
|
|
658
|
-
];
|
|
659
|
-
const customSignatureType = {
|
|
660
|
-
MetaTxExchange: metaTransactionType,
|
|
661
|
-
MetaTxExchangeDetails: exchangeType
|
|
662
|
-
};
|
|
663
|
-
const buyerAddress = await args.web3Lib.getSignerAddress();
|
|
664
|
-
const message = {
|
|
665
|
-
nonce: args.nonce.toString(),
|
|
666
|
-
from: buyerAddress,
|
|
667
|
-
contractAddress: args.metaTxHandlerAddress,
|
|
668
|
-
functionName,
|
|
669
|
-
exchangeDetails: {
|
|
670
|
-
exchangeId: args.exchangeId.toString()
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
const signatureParams = await prepareDataSignatureParameters({
|
|
674
|
-
...args,
|
|
675
|
-
verifyingContractAddress: args.metaTxHandlerAddress,
|
|
676
|
-
customSignatureType,
|
|
677
|
-
primaryType: "MetaTxExchange",
|
|
678
|
-
message
|
|
679
|
-
});
|
|
680
|
-
return {
|
|
681
|
-
...signatureParams,
|
|
682
|
-
functionName,
|
|
683
|
-
functionSignature: handlerIface.encodeFunctionData(
|
|
684
|
-
// remove params in brackets from string
|
|
685
|
-
functionName.replace(/\(([^)]*)\)[^(]*$/, ""), [args.exchangeId])
|
|
686
|
-
};
|
|
687
|
-
};
|
|
688
|
-
}
|
|
689
|
-
export async function relayMetaTransaction(args) {
|
|
690
|
-
const { chainId, contractAddress, metaTx } = args;
|
|
691
|
-
const biconomy = new Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
692
|
-
const relayTxResponse = await biconomy.relayTransaction({
|
|
693
|
-
to: contractAddress,
|
|
694
|
-
params: [
|
|
695
|
-
metaTx.params.userAddress,
|
|
696
|
-
metaTx.params.functionName,
|
|
697
|
-
metaTx.params.functionSignature,
|
|
698
|
-
metaTx.params.nonce,
|
|
699
|
-
metaTx.params.sigR,
|
|
700
|
-
metaTx.params.sigS,
|
|
701
|
-
metaTx.params.sigV
|
|
702
|
-
],
|
|
703
|
-
from: metaTx.params.userAddress
|
|
704
|
-
});
|
|
705
|
-
return {
|
|
706
|
-
wait: async () => {
|
|
707
|
-
const waitResponse = await biconomy.wait({
|
|
708
|
-
networkId: chainId,
|
|
709
|
-
transactionHash: relayTxResponse.txHash
|
|
710
|
-
});
|
|
711
|
-
const txHash = waitResponse.data.newHash;
|
|
712
|
-
const txReceipt = await args.web3LibAdapter.getTransactionReceipt(txHash);
|
|
713
|
-
console.log("[relayBiconomyMetaTransaction.wait] txReceipt", txReceipt);
|
|
714
|
-
return {
|
|
715
|
-
to: txReceipt?.to || contractAddress,
|
|
716
|
-
from: txReceipt?.from || metaTx.params.userAddress,
|
|
717
|
-
transactionHash: txHash,
|
|
718
|
-
logs: txReceipt?.logs || [],
|
|
719
|
-
effectiveGasPrice: BigNumber.from(waitResponse.data.newGasPrice)
|
|
720
|
-
};
|
|
721
|
-
},
|
|
722
|
-
hash: relayTxResponse.txHash
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
export async function getResubmitted(args) {
|
|
726
|
-
const { chainId, metaTx } = args;
|
|
727
|
-
const biconomy = new Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
728
|
-
const retriedHashesResponse = await biconomy.getResubmitted({
|
|
729
|
-
networkId: chainId,
|
|
730
|
-
transactionHash: metaTx.originalHash
|
|
731
|
-
});
|
|
732
|
-
return retriedHashesResponse.data;
|
|
733
|
-
}
|
|
1
|
+
import { utils, defaultConfigs } from "@bosonprotocol/common";
|
|
2
|
+
import { storeMetadataOnTheGraph } from "../offers/storage";
|
|
3
|
+
import { BigNumber } from "@ethersproject/bignumber";
|
|
4
|
+
import { encodeCreateSeller, encodeOptInToSellerUpdate, encodeUpdateSeller } from "../accounts/interface";
|
|
5
|
+
import { bosonExchangeHandlerIface } from "../exchanges/interface";
|
|
6
|
+
import { bosonOfferHandlerIface, encodeCreateOffer, encodeCreateOfferBatch, encodeReserveRange } from "../offers/interface";
|
|
7
|
+
import { prepareDataSignatureParameters } from "../utils/signature";
|
|
8
|
+
import { Biconomy } from "./biconomy";
|
|
9
|
+
import { isAddress } from "@ethersproject/address";
|
|
10
|
+
import { AddressZero } from "@ethersproject/constants";
|
|
11
|
+
import { encodeDepositFunds, encodeWithdrawFunds } from "../funds/interface";
|
|
12
|
+
import { bosonDisputeHandlerIface } from "../disputes/interface";
|
|
13
|
+
import { encodeCreateGroup } from "../groups/interface";
|
|
14
|
+
import { encodeCreateOfferWithCondition } from "../orchestration/interface";
|
|
15
|
+
import { encodeCallExternalContract, encodePreMint, encodeSetApprovalForAll, encodeSetApprovalForAllToContract } from "../voucher/interface";
|
|
16
|
+
import { keccak256 } from "@ethersproject/keccak256";
|
|
17
|
+
import { id } from "@ethersproject/hash";
|
|
18
|
+
import { defaultAbiCoder } from "@ethersproject/abi";
|
|
19
|
+
import { getNonce, verifyEIP712 } from "../forwarder/handler";
|
|
20
|
+
import { isTrustedForwarder } from "../voucher/handler";
|
|
21
|
+
export async function signMetaTx(args) {
|
|
22
|
+
const metaTransactionType = [
|
|
23
|
+
{ name: "nonce", type: "uint256" },
|
|
24
|
+
{ name: "from", type: "address" },
|
|
25
|
+
{ name: "contractAddress", type: "address" },
|
|
26
|
+
{ name: "functionName", type: "string" },
|
|
27
|
+
{ name: "functionSignature", type: "bytes" }
|
|
28
|
+
];
|
|
29
|
+
const customSignatureType = {
|
|
30
|
+
MetaTransaction: metaTransactionType
|
|
31
|
+
};
|
|
32
|
+
const signerAddress = await args.web3Lib.getSignerAddress();
|
|
33
|
+
const message = {
|
|
34
|
+
nonce: args.nonce,
|
|
35
|
+
from: signerAddress,
|
|
36
|
+
contractAddress: args.metaTxHandlerAddress,
|
|
37
|
+
functionName: args.functionName,
|
|
38
|
+
functionSignature: args.functionSignature
|
|
39
|
+
};
|
|
40
|
+
const signature = await prepareDataSignatureParameters({
|
|
41
|
+
...args,
|
|
42
|
+
verifyingContractAddress: args.metaTxHandlerAddress,
|
|
43
|
+
customSignatureType,
|
|
44
|
+
primaryType: "MetaTransaction",
|
|
45
|
+
message
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
functionName: args.functionName,
|
|
49
|
+
functionSignature: args.functionSignature,
|
|
50
|
+
...signature
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export async function signVoucherMetaTx(args) {
|
|
54
|
+
const forwardType = [
|
|
55
|
+
{ name: "from", type: "address" },
|
|
56
|
+
{ name: "to", type: "address" },
|
|
57
|
+
{ name: "nonce", type: "uint256" },
|
|
58
|
+
{ name: "data", type: "bytes" }
|
|
59
|
+
];
|
|
60
|
+
const customSignatureType = {
|
|
61
|
+
EIP712Domain: [
|
|
62
|
+
{ name: "name", type: "string" },
|
|
63
|
+
{ name: "version", type: "string" },
|
|
64
|
+
{ name: "chainId", type: "uint256" },
|
|
65
|
+
{ name: "verifyingContract", type: "address" }
|
|
66
|
+
],
|
|
67
|
+
ForwardRequest: forwardType
|
|
68
|
+
};
|
|
69
|
+
const signerAddress = await args.web3Lib.getSignerAddress();
|
|
70
|
+
const chainId = await args.web3Lib.getChainId();
|
|
71
|
+
const nonce = await getNonce({
|
|
72
|
+
contractAddress: args.forwarderAddress,
|
|
73
|
+
user: signerAddress,
|
|
74
|
+
web3Lib: args.web3Lib,
|
|
75
|
+
forwarderAbi: args.forwarderAbi
|
|
76
|
+
});
|
|
77
|
+
const message = {
|
|
78
|
+
from: signerAddress,
|
|
79
|
+
to: args.bosonVoucherAddress,
|
|
80
|
+
nonce,
|
|
81
|
+
data: args.functionSignature
|
|
82
|
+
};
|
|
83
|
+
const signature = await prepareDataSignatureParameters({
|
|
84
|
+
...args,
|
|
85
|
+
verifyingContractAddress: args.forwarderAddress,
|
|
86
|
+
customSignatureType,
|
|
87
|
+
primaryType: "ForwardRequest",
|
|
88
|
+
message,
|
|
89
|
+
customDomainData: {
|
|
90
|
+
name: "MockForwarder",
|
|
91
|
+
version: "0.0.1",
|
|
92
|
+
chainId,
|
|
93
|
+
salt: undefined
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
to: message.to,
|
|
98
|
+
functionSignature: args.functionSignature,
|
|
99
|
+
request: message,
|
|
100
|
+
...signature
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export async function signBiconomyVoucherMetaTx(args) {
|
|
104
|
+
const customSignatureType = {
|
|
105
|
+
EIP712Domain: [
|
|
106
|
+
{ name: "name", type: "string" },
|
|
107
|
+
{ name: "version", type: "string" },
|
|
108
|
+
// { name: "chainId", type: "uint256" },
|
|
109
|
+
// { name: "verifyingContract", type: "address" }
|
|
110
|
+
{ name: "verifyingContract", type: "address" },
|
|
111
|
+
{ name: "salt", type: "bytes32" }
|
|
112
|
+
],
|
|
113
|
+
ERC20ForwardRequest: [
|
|
114
|
+
{ name: "from", type: "address" },
|
|
115
|
+
{ name: "to", type: "address" },
|
|
116
|
+
{ name: "token", type: "address" },
|
|
117
|
+
{ name: "txGas", type: "uint256" },
|
|
118
|
+
{ name: "tokenGasPrice", type: "uint256" },
|
|
119
|
+
{ name: "batchId", type: "uint256" },
|
|
120
|
+
{ name: "batchNonce", type: "uint256" },
|
|
121
|
+
{ name: "deadline", type: "uint256" },
|
|
122
|
+
{ name: "data", type: "bytes" }
|
|
123
|
+
]
|
|
124
|
+
};
|
|
125
|
+
const signerAddress = await args.web3Lib.getSignerAddress();
|
|
126
|
+
const chainId = await args.web3Lib.getChainId();
|
|
127
|
+
// Check which forwarder needs to be used for the contract
|
|
128
|
+
const biconomyForwarderDomainDetails = await new Biconomy(args.relayerUrl).getForwarderDomainDetails({ chainId });
|
|
129
|
+
const biconomyForwarderDomainData = await new Promise(async (resolve, reject) => {
|
|
130
|
+
try {
|
|
131
|
+
for (const bFDD of Object.values(biconomyForwarderDomainDetails)) {
|
|
132
|
+
const ret = await isTrustedForwarder({
|
|
133
|
+
forwarder: bFDD.verifyingContract,
|
|
134
|
+
contractAddress: args.bosonVoucherAddress,
|
|
135
|
+
web3Lib: args.web3Lib
|
|
136
|
+
});
|
|
137
|
+
if (ret) {
|
|
138
|
+
resolve(bFDD);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
resolve(undefined);
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
reject(e);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
if (!biconomyForwarderDomainData) {
|
|
148
|
+
throw `Unable to find the trusted forwarder for BosonVoucher contract ${args.bosonVoucherAddress}`;
|
|
149
|
+
}
|
|
150
|
+
const nonce = await getNonce({
|
|
151
|
+
contractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
152
|
+
user: signerAddress,
|
|
153
|
+
web3Lib: args.web3Lib,
|
|
154
|
+
batchId: args.batchId,
|
|
155
|
+
forwarderAbi: args.forwarderAbi
|
|
156
|
+
});
|
|
157
|
+
const message = {
|
|
158
|
+
from: signerAddress,
|
|
159
|
+
to: args.bosonVoucherAddress,
|
|
160
|
+
token: "0x0000000000000000000000000000000000000000",
|
|
161
|
+
txGas: args.txGas,
|
|
162
|
+
tokenGasPrice: "0",
|
|
163
|
+
batchId: args.batchId,
|
|
164
|
+
batchNonce: nonce,
|
|
165
|
+
deadline: Math.floor(Date.now() / 1000 + 3600),
|
|
166
|
+
data: args.functionSignature
|
|
167
|
+
};
|
|
168
|
+
const signatureParams = await prepareDataSignatureParameters({
|
|
169
|
+
...args,
|
|
170
|
+
chainId,
|
|
171
|
+
verifyingContractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
172
|
+
customSignatureType,
|
|
173
|
+
primaryType: "ERC20ForwardRequest",
|
|
174
|
+
message,
|
|
175
|
+
customDomainData: {
|
|
176
|
+
...biconomyForwarderDomainData
|
|
177
|
+
// chainId
|
|
178
|
+
// salt: undefined
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
const signature = signatureParams.signature;
|
|
182
|
+
const getDomainSeparator = async () => {
|
|
183
|
+
const domainData = biconomyForwarderDomainData;
|
|
184
|
+
const domainSeparator = keccak256(defaultAbiCoder.encode(["bytes32", "bytes32", "bytes32", "address", "bytes32"], [
|
|
185
|
+
id("EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)"),
|
|
186
|
+
id(domainData.name),
|
|
187
|
+
id(domainData.version),
|
|
188
|
+
domainData.verifyingContract,
|
|
189
|
+
domainData.salt
|
|
190
|
+
]));
|
|
191
|
+
return domainSeparator;
|
|
192
|
+
};
|
|
193
|
+
const domainSeparator = await getDomainSeparator();
|
|
194
|
+
// verify signature
|
|
195
|
+
const signatureVerified = await verifyEIP712({
|
|
196
|
+
request: message,
|
|
197
|
+
contractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
198
|
+
web3Lib: args.web3Lib,
|
|
199
|
+
domainSeparator,
|
|
200
|
+
forwarderAbi: args.forwarderAbi,
|
|
201
|
+
signature
|
|
202
|
+
});
|
|
203
|
+
if (!signatureVerified) {
|
|
204
|
+
throw `Signature is not verified`;
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
to: message.to,
|
|
208
|
+
domainSeparator,
|
|
209
|
+
request: message,
|
|
210
|
+
...signatureParams,
|
|
211
|
+
signature,
|
|
212
|
+
functionSignature: args.functionSignature
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
export async function relayBiconomyMetaTransaction(args) {
|
|
216
|
+
const { chainId, contractAddress, metaTx } = args;
|
|
217
|
+
const biconomy = new Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
218
|
+
const relayTxResponse = await biconomy.relayTransaction({
|
|
219
|
+
to: contractAddress,
|
|
220
|
+
params: [
|
|
221
|
+
metaTx.params.request,
|
|
222
|
+
metaTx.params.domainSeparator,
|
|
223
|
+
metaTx.params.signature
|
|
224
|
+
],
|
|
225
|
+
from: metaTx.params.userAddress,
|
|
226
|
+
signatureType: "EIP712_SIGN"
|
|
227
|
+
});
|
|
228
|
+
return {
|
|
229
|
+
wait: async () => {
|
|
230
|
+
const waitResponse = await biconomy.wait({
|
|
231
|
+
networkId: chainId,
|
|
232
|
+
transactionHash: relayTxResponse.txHash
|
|
233
|
+
});
|
|
234
|
+
const txHash = waitResponse.data.newHash;
|
|
235
|
+
const txReceipt = await args.web3LibAdapter.getTransactionReceipt(txHash);
|
|
236
|
+
return {
|
|
237
|
+
to: txReceipt?.to || contractAddress,
|
|
238
|
+
from: txReceipt?.from || metaTx.params.userAddress,
|
|
239
|
+
transactionHash: txHash,
|
|
240
|
+
logs: txReceipt?.logs || [],
|
|
241
|
+
effectiveGasPrice: BigNumber.from(waitResponse.data.newGasPrice)
|
|
242
|
+
};
|
|
243
|
+
},
|
|
244
|
+
hash: relayTxResponse.txHash
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
export async function signMetaTxCreateSeller(args) {
|
|
248
|
+
await storeMetadataOnTheGraph({
|
|
249
|
+
metadataUriOrHash: args.createSellerArgs.metadataUri,
|
|
250
|
+
metadataStorage: args.metadataStorage,
|
|
251
|
+
theGraphStorage: args.theGraphStorage
|
|
252
|
+
});
|
|
253
|
+
return signMetaTx({
|
|
254
|
+
...args,
|
|
255
|
+
functionName: "createSeller((uint256,address,address,address,address,bool,string),(uint256,uint8),(string,uint256))",
|
|
256
|
+
functionSignature: encodeCreateSeller(args.createSellerArgs)
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
export async function signMetaTxUpdateSeller(args) {
|
|
260
|
+
await storeMetadataOnTheGraph({
|
|
261
|
+
metadataUriOrHash: args.updateSellerArgs.metadataUri,
|
|
262
|
+
metadataStorage: args.metadataStorage,
|
|
263
|
+
theGraphStorage: args.theGraphStorage
|
|
264
|
+
});
|
|
265
|
+
return signMetaTx({
|
|
266
|
+
...args,
|
|
267
|
+
functionName: "updateSeller((uint256,address,address,address,address,bool,string),(uint256,uint8))",
|
|
268
|
+
functionSignature: encodeUpdateSeller(args.updateSellerArgs)
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
export async function signMetaTxOptInToSellerUpdate(args) {
|
|
272
|
+
return signMetaTx({
|
|
273
|
+
...args,
|
|
274
|
+
functionName: "optInToSellerUpdate(uint256,uint8[])",
|
|
275
|
+
functionSignature: encodeOptInToSellerUpdate(args.optInToSellerUpdateArgs)
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
export async function signMetaTxCreateOffer(args) {
|
|
279
|
+
utils.validation.createOfferArgsSchema.validateSync(args.createOfferArgs, {
|
|
280
|
+
abortEarly: false
|
|
281
|
+
});
|
|
282
|
+
await storeMetadataOnTheGraph({
|
|
283
|
+
metadataUriOrHash: args.createOfferArgs.metadataUri,
|
|
284
|
+
metadataStorage: args.metadataStorage,
|
|
285
|
+
theGraphStorage: args.theGraphStorage
|
|
286
|
+
});
|
|
287
|
+
return signMetaTx({
|
|
288
|
+
...args,
|
|
289
|
+
functionName: "createOffer((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,uint256)",
|
|
290
|
+
functionSignature: encodeCreateOffer(args.createOfferArgs)
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
export async function signMetaTxCreateOfferBatch(args) {
|
|
294
|
+
for (const offerToCreate of args.createOffersArgs) {
|
|
295
|
+
utils.validation.createOfferArgsSchema.validateSync(offerToCreate, {
|
|
296
|
+
abortEarly: false
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
await Promise.all(args.createOffersArgs.map((offerToCreate) => storeMetadataOnTheGraph({
|
|
300
|
+
metadataUriOrHash: offerToCreate.metadataUri,
|
|
301
|
+
metadataStorage: args.metadataStorage,
|
|
302
|
+
theGraphStorage: args.theGraphStorage
|
|
303
|
+
})));
|
|
304
|
+
return signMetaTx({
|
|
305
|
+
...args,
|
|
306
|
+
functionName: "createOfferBatch((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool)[],(uint256,uint256,uint256,uint256)[],(uint256,uint256,uint256)[],uint256[],uint256[])",
|
|
307
|
+
functionSignature: encodeCreateOfferBatch(args.createOffersArgs)
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
export async function signMetaTxVoidOffer(args) {
|
|
311
|
+
return signMetaTx({
|
|
312
|
+
...args,
|
|
313
|
+
functionName: "voidOffer(uint256)",
|
|
314
|
+
functionSignature: bosonOfferHandlerIface.encodeFunctionData("voidOffer", [
|
|
315
|
+
args.offerId
|
|
316
|
+
])
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
export async function signMetaTxVoidOfferBatch(args) {
|
|
320
|
+
return signMetaTx({
|
|
321
|
+
...args,
|
|
322
|
+
functionName: "voidOfferBatch(uint256[])",
|
|
323
|
+
functionSignature: bosonOfferHandlerIface.encodeFunctionData("voidOfferBatch", [args.offerIds])
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
export async function signMetaTxExtendOffer(args) {
|
|
327
|
+
return signMetaTx({
|
|
328
|
+
...args,
|
|
329
|
+
functionName: "extendOffer(uint256,uint256)",
|
|
330
|
+
functionSignature: bosonOfferHandlerIface.encodeFunctionData("extendOffer", [args.offerId, args.validUntil])
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
export async function signMetaTxExtendOfferBatch(args) {
|
|
334
|
+
return signMetaTx({
|
|
335
|
+
...args,
|
|
336
|
+
functionName: "extendOfferBatch(uint256[],uint256)",
|
|
337
|
+
functionSignature: bosonOfferHandlerIface.encodeFunctionData("extendOfferBatch", [args.offerIds, args.validUntil])
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
export async function signMetaTxCompleteExchangeBatch(args) {
|
|
341
|
+
return signMetaTx({
|
|
342
|
+
...args,
|
|
343
|
+
functionName: "completeExchangeBatch(uint256[])",
|
|
344
|
+
functionSignature: bosonExchangeHandlerIface.encodeFunctionData("completeExchangeBatch", [args.exchangeIds])
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
export async function signMetaTxExpireVoucher(args) {
|
|
348
|
+
return signMetaTx({
|
|
349
|
+
...args,
|
|
350
|
+
functionName: "expireVoucher(uint256)",
|
|
351
|
+
functionSignature: bosonExchangeHandlerIface.encodeFunctionData("expireVoucher", [args.exchangeId])
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
export async function signMetaTxRevokeVoucher(args) {
|
|
355
|
+
return signMetaTx({
|
|
356
|
+
...args,
|
|
357
|
+
functionName: "revokeVoucher(uint256)",
|
|
358
|
+
functionSignature: bosonExchangeHandlerIface.encodeFunctionData("revokeVoucher", [args.exchangeId])
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
export async function signMetaTxCreateGroup(args) {
|
|
362
|
+
return signMetaTx({
|
|
363
|
+
...args,
|
|
364
|
+
functionName: "createGroup((uint256,uint256,uint256[]),(uint8,uint8,address,uint256,uint256,uint256))",
|
|
365
|
+
functionSignature: encodeCreateGroup(args.createGroupArgs)
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
export async function signMetaTxReserveRange(args) {
|
|
369
|
+
return signMetaTx({
|
|
370
|
+
...args,
|
|
371
|
+
functionName: "reserveRange(uint256,uint256,address)",
|
|
372
|
+
functionSignature: encodeReserveRange(args.offerId, args.length, args.to)
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
export async function signMetaTxPreMint(args) {
|
|
376
|
+
const localConfig = defaultConfigs.find((config) => config.envName === "local");
|
|
377
|
+
const isLocal = localConfig.chainId === args.chainId;
|
|
378
|
+
const functionSignature = encodePreMint(args.offerId, args.amount);
|
|
379
|
+
if (isLocal) {
|
|
380
|
+
return signVoucherMetaTx({
|
|
381
|
+
...args,
|
|
382
|
+
forwarderAddress: args.forwarderAddress,
|
|
383
|
+
functionSignature,
|
|
384
|
+
forwarderAbi: args.forwarderAbi
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
const txGas = 200000 + BigNumber.from(args.amount).mul(2500).toNumber(); // ~(180000 + 2250*N) estimation on 2023/02/03
|
|
388
|
+
return signBiconomyVoucherMetaTx({
|
|
389
|
+
...args,
|
|
390
|
+
functionSignature,
|
|
391
|
+
forwarderAbi: args.forwarderAbi,
|
|
392
|
+
batchId: args.batchId || "0",
|
|
393
|
+
txGas
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
export async function signMetaTxSetApprovalForAll(args) {
|
|
397
|
+
const localConfig = defaultConfigs.find((config) => config.envName === "local");
|
|
398
|
+
const isLocal = localConfig.chainId === args.chainId;
|
|
399
|
+
const functionSignature = encodeSetApprovalForAll(args.operator, args.approved);
|
|
400
|
+
if (isLocal) {
|
|
401
|
+
return signVoucherMetaTx({
|
|
402
|
+
...args,
|
|
403
|
+
forwarderAddress: args.forwarderAddress,
|
|
404
|
+
functionSignature,
|
|
405
|
+
forwarderAbi: args.forwarderAbi
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
const txGas = 100000; // ~70000 estimation on 2023/02/03
|
|
409
|
+
return signBiconomyVoucherMetaTx({
|
|
410
|
+
...args,
|
|
411
|
+
functionSignature,
|
|
412
|
+
forwarderAbi: args.forwarderAbi,
|
|
413
|
+
batchId: args.batchId || "0",
|
|
414
|
+
txGas
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
export async function signMetaTxSetApprovalForAllToContract(args, overrides = {}) {
|
|
418
|
+
const localConfig = defaultConfigs.find((config) => config.envName === "local");
|
|
419
|
+
const isLocal = localConfig.chainId === args.chainId;
|
|
420
|
+
const functionSignature = encodeSetApprovalForAllToContract(args.operator, args.approved);
|
|
421
|
+
if (isLocal) {
|
|
422
|
+
return signVoucherMetaTx({
|
|
423
|
+
...args,
|
|
424
|
+
forwarderAddress: args.forwarderAddress,
|
|
425
|
+
functionSignature,
|
|
426
|
+
forwarderAbi: args.forwarderAbi
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
const txGas = overrides.txGas || 100000; // TODO: estimate the gas needed
|
|
430
|
+
return signBiconomyVoucherMetaTx({
|
|
431
|
+
...args,
|
|
432
|
+
functionSignature,
|
|
433
|
+
forwarderAbi: args.forwarderAbi,
|
|
434
|
+
batchId: args.batchId || "0",
|
|
435
|
+
txGas
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
export async function signMetaTxCallExternalContract(args, overrides = {}) {
|
|
439
|
+
const localConfig = defaultConfigs.find((config) => config.envName === "local");
|
|
440
|
+
const isLocal = localConfig.chainId === args.chainId;
|
|
441
|
+
const functionSignature = encodeCallExternalContract(args.to, args.data);
|
|
442
|
+
if (isLocal) {
|
|
443
|
+
return signVoucherMetaTx({
|
|
444
|
+
...args,
|
|
445
|
+
forwarderAddress: args.forwarderAddress,
|
|
446
|
+
functionSignature,
|
|
447
|
+
forwarderAbi: args.forwarderAbi
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
const txGas = overrides.txGas || 500000; // TODO: estimate the gas needed
|
|
451
|
+
return signBiconomyVoucherMetaTx({
|
|
452
|
+
...args,
|
|
453
|
+
functionSignature,
|
|
454
|
+
forwarderAbi: args.forwarderAbi,
|
|
455
|
+
batchId: args.batchId || "0",
|
|
456
|
+
txGas
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
export async function signMetaTxCreateOfferWithCondition(args) {
|
|
460
|
+
utils.validation.createOfferArgsSchema.validateSync(args.offerToCreate, {
|
|
461
|
+
abortEarly: false
|
|
462
|
+
});
|
|
463
|
+
await storeMetadataOnTheGraph({
|
|
464
|
+
metadataUriOrHash: args.offerToCreate.metadataUri,
|
|
465
|
+
metadataStorage: args.metadataStorage,
|
|
466
|
+
theGraphStorage: args.theGraphStorage
|
|
467
|
+
});
|
|
468
|
+
return signMetaTx({
|
|
469
|
+
...args,
|
|
470
|
+
functionName: "createOfferWithCondition((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,(uint8,uint8,address,uint256,uint256,uint256),uint256)",
|
|
471
|
+
functionSignature: encodeCreateOfferWithCondition(args.offerToCreate, args.condition)
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
export async function signMetaTxCommitToOffer(args) {
|
|
475
|
+
const functionName = "commitToOffer(address,uint256)";
|
|
476
|
+
const offerType = [
|
|
477
|
+
{ name: "buyer", type: "address" },
|
|
478
|
+
{ name: "offerId", type: "uint256" }
|
|
479
|
+
];
|
|
480
|
+
const metaTransactionType = [
|
|
481
|
+
{ name: "nonce", type: "uint256" },
|
|
482
|
+
{ name: "from", type: "address" },
|
|
483
|
+
{ name: "contractAddress", type: "address" },
|
|
484
|
+
{ name: "functionName", type: "string" },
|
|
485
|
+
{ name: "offerDetails", type: "MetaTxOfferDetails" }
|
|
486
|
+
];
|
|
487
|
+
const customSignatureType = {
|
|
488
|
+
MetaTxCommitToOffer: metaTransactionType,
|
|
489
|
+
MetaTxOfferDetails: offerType
|
|
490
|
+
};
|
|
491
|
+
const buyerAddress = await args.web3Lib.getSignerAddress();
|
|
492
|
+
const message = {
|
|
493
|
+
nonce: args.nonce.toString(),
|
|
494
|
+
from: buyerAddress,
|
|
495
|
+
contractAddress: args.metaTxHandlerAddress,
|
|
496
|
+
functionName,
|
|
497
|
+
offerDetails: {
|
|
498
|
+
buyer: buyerAddress,
|
|
499
|
+
offerId: args.offerId.toString()
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
const signatureParams = await prepareDataSignatureParameters({
|
|
503
|
+
...args,
|
|
504
|
+
verifyingContractAddress: args.metaTxHandlerAddress,
|
|
505
|
+
customSignatureType,
|
|
506
|
+
primaryType: "MetaTxCommitToOffer",
|
|
507
|
+
message
|
|
508
|
+
});
|
|
509
|
+
return {
|
|
510
|
+
...signatureParams,
|
|
511
|
+
functionName,
|
|
512
|
+
functionSignature: bosonExchangeHandlerIface.encodeFunctionData("commitToOffer", [buyerAddress, args.offerId])
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
export async function signMetaTxCancelVoucher(args) {
|
|
516
|
+
return makeExchangeMetaTxSigner("cancelVoucher(uint256)")(args);
|
|
517
|
+
}
|
|
518
|
+
export async function signMetaTxRedeemVoucher(args) {
|
|
519
|
+
return makeExchangeMetaTxSigner("redeemVoucher(uint256)")(args);
|
|
520
|
+
}
|
|
521
|
+
export async function signMetaTxCompleteExchange(args) {
|
|
522
|
+
return makeExchangeMetaTxSigner("completeExchange(uint256)")(args);
|
|
523
|
+
}
|
|
524
|
+
export async function signMetaTxRetractDispute(args) {
|
|
525
|
+
return makeExchangeMetaTxSigner("retractDispute(uint256)", bosonDisputeHandlerIface)(args);
|
|
526
|
+
}
|
|
527
|
+
export async function signMetaTxEscalateDispute(args) {
|
|
528
|
+
return makeExchangeMetaTxSigner("escalateDispute(uint256)", bosonDisputeHandlerIface)(args);
|
|
529
|
+
}
|
|
530
|
+
export async function signMetaTxRaiseDispute(args) {
|
|
531
|
+
return makeExchangeMetaTxSigner("raiseDispute(uint256)", bosonDisputeHandlerIface)(args);
|
|
532
|
+
}
|
|
533
|
+
export async function signMetaTxResolveDispute(args) {
|
|
534
|
+
const functionName = "resolveDispute(uint256,uint256,bytes32,bytes32,uint8)";
|
|
535
|
+
const disputeResolutionType = [
|
|
536
|
+
{ name: "exchangeId", type: "uint256" },
|
|
537
|
+
{ name: "buyerPercentBasisPoints", type: "uint256" },
|
|
538
|
+
{ name: "sigR", type: "bytes32" },
|
|
539
|
+
{ name: "sigS", type: "bytes32" },
|
|
540
|
+
{ name: "sigV", type: "uint8" }
|
|
541
|
+
];
|
|
542
|
+
const metaTransactionType = [
|
|
543
|
+
{ name: "nonce", type: "uint256" },
|
|
544
|
+
{ name: "from", type: "address" },
|
|
545
|
+
{ name: "contractAddress", type: "address" },
|
|
546
|
+
{ name: "functionName", type: "string" },
|
|
547
|
+
{ name: "disputeResolutionDetails", type: "MetaTxDisputeResolutionDetails" }
|
|
548
|
+
];
|
|
549
|
+
const customSignatureType = {
|
|
550
|
+
MetaTxDisputeResolution: metaTransactionType,
|
|
551
|
+
MetaTxDisputeResolutionDetails: disputeResolutionType
|
|
552
|
+
};
|
|
553
|
+
const message = {
|
|
554
|
+
nonce: args.nonce.toString(),
|
|
555
|
+
from: await args.web3Lib.getSignerAddress(),
|
|
556
|
+
contractAddress: args.metaTxHandlerAddress,
|
|
557
|
+
functionName,
|
|
558
|
+
disputeResolutionDetails: {
|
|
559
|
+
exchangeId: args.exchangeId.toString(),
|
|
560
|
+
buyerPercentBasisPoints: args.buyerPercent.toString(),
|
|
561
|
+
sigR: args.counterpartySig.r,
|
|
562
|
+
sigS: args.counterpartySig.s,
|
|
563
|
+
sigV: args.counterpartySig.v
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
const signatureParams = await prepareDataSignatureParameters({
|
|
567
|
+
...args,
|
|
568
|
+
verifyingContractAddress: args.metaTxHandlerAddress,
|
|
569
|
+
customSignatureType,
|
|
570
|
+
primaryType: "MetaTxDisputeResolution",
|
|
571
|
+
message
|
|
572
|
+
});
|
|
573
|
+
return {
|
|
574
|
+
...signatureParams,
|
|
575
|
+
functionName,
|
|
576
|
+
functionSignature: bosonDisputeHandlerIface.encodeFunctionData(
|
|
577
|
+
// remove params in brackets from string
|
|
578
|
+
functionName.replace(/\(([^)]*)\)[^(]*$/, ""), [
|
|
579
|
+
args.exchangeId,
|
|
580
|
+
args.buyerPercent,
|
|
581
|
+
args.counterpartySig.r,
|
|
582
|
+
args.counterpartySig.s,
|
|
583
|
+
args.counterpartySig.v
|
|
584
|
+
])
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
export async function signMetaTxExtendDisputeTimeout(args) {
|
|
588
|
+
return signMetaTx({
|
|
589
|
+
...args,
|
|
590
|
+
functionName: "extendDisputeTimeout(uint256,uint256)",
|
|
591
|
+
functionSignature: bosonDisputeHandlerIface.encodeFunctionData("extendDisputeTimeout", [args.exchangeId, args.newTimeout])
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
export async function signMetaTxWithdrawFunds(args) {
|
|
595
|
+
const functionName = "withdrawFunds(uint256,address[],uint256[])";
|
|
596
|
+
const fundType = [
|
|
597
|
+
{ name: "entityId", type: "uint256" },
|
|
598
|
+
{ name: "tokenList", type: "address[]" },
|
|
599
|
+
{ name: "tokenAmounts", type: "uint256[]" }
|
|
600
|
+
];
|
|
601
|
+
const metaTransactionType = [
|
|
602
|
+
{ name: "nonce", type: "uint256" },
|
|
603
|
+
{ name: "from", type: "address" },
|
|
604
|
+
{ name: "contractAddress", type: "address" },
|
|
605
|
+
{ name: "functionName", type: "string" },
|
|
606
|
+
{ name: "fundDetails", type: "MetaTxFundDetails" }
|
|
607
|
+
];
|
|
608
|
+
const customSignatureType = {
|
|
609
|
+
MetaTxFund: metaTransactionType,
|
|
610
|
+
MetaTxFundDetails: fundType
|
|
611
|
+
};
|
|
612
|
+
const message = {
|
|
613
|
+
nonce: args.nonce.toString(),
|
|
614
|
+
from: await args.web3Lib.getSignerAddress(),
|
|
615
|
+
contractAddress: args.metaTxHandlerAddress,
|
|
616
|
+
functionName,
|
|
617
|
+
fundDetails: {
|
|
618
|
+
entityId: args.entityId.toString(),
|
|
619
|
+
tokenList: args.tokenList,
|
|
620
|
+
tokenAmounts: args.tokenAmounts.map((bn) => bn.toString())
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
const signatureParams = await prepareDataSignatureParameters({
|
|
624
|
+
...args,
|
|
625
|
+
verifyingContractAddress: args.metaTxHandlerAddress,
|
|
626
|
+
customSignatureType,
|
|
627
|
+
primaryType: "MetaTxFund",
|
|
628
|
+
message
|
|
629
|
+
});
|
|
630
|
+
return {
|
|
631
|
+
...signatureParams,
|
|
632
|
+
functionName,
|
|
633
|
+
functionSignature: encodeWithdrawFunds(args.entityId, args.tokenList, args.tokenAmounts)
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
export async function signMetaTxDepositFunds(args) {
|
|
637
|
+
if (!isAddress(args.fundsTokenAddress)) {
|
|
638
|
+
throw new Error(`Invalid fundsTokenAddress: ${args.fundsTokenAddress}`);
|
|
639
|
+
}
|
|
640
|
+
if (args.fundsTokenAddress === AddressZero) {
|
|
641
|
+
throw new Error(`Meta transaction can't be used to deposit native currency`);
|
|
642
|
+
}
|
|
643
|
+
return signMetaTx({
|
|
644
|
+
...args,
|
|
645
|
+
functionName: "depositFunds(uint256,address,uint256)",
|
|
646
|
+
functionSignature: encodeDepositFunds(args.sellerId, args.fundsTokenAddress, args.fundsAmount)
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
function makeExchangeMetaTxSigner(functionName, handlerIface = bosonExchangeHandlerIface) {
|
|
650
|
+
return async function signExchangeMetaTx(args) {
|
|
651
|
+
const exchangeType = [{ name: "exchangeId", type: "uint256" }];
|
|
652
|
+
const metaTransactionType = [
|
|
653
|
+
{ name: "nonce", type: "uint256" },
|
|
654
|
+
{ name: "from", type: "address" },
|
|
655
|
+
{ name: "contractAddress", type: "address" },
|
|
656
|
+
{ name: "functionName", type: "string" },
|
|
657
|
+
{ name: "exchangeDetails", type: "MetaTxExchangeDetails" }
|
|
658
|
+
];
|
|
659
|
+
const customSignatureType = {
|
|
660
|
+
MetaTxExchange: metaTransactionType,
|
|
661
|
+
MetaTxExchangeDetails: exchangeType
|
|
662
|
+
};
|
|
663
|
+
const buyerAddress = await args.web3Lib.getSignerAddress();
|
|
664
|
+
const message = {
|
|
665
|
+
nonce: args.nonce.toString(),
|
|
666
|
+
from: buyerAddress,
|
|
667
|
+
contractAddress: args.metaTxHandlerAddress,
|
|
668
|
+
functionName,
|
|
669
|
+
exchangeDetails: {
|
|
670
|
+
exchangeId: args.exchangeId.toString()
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
const signatureParams = await prepareDataSignatureParameters({
|
|
674
|
+
...args,
|
|
675
|
+
verifyingContractAddress: args.metaTxHandlerAddress,
|
|
676
|
+
customSignatureType,
|
|
677
|
+
primaryType: "MetaTxExchange",
|
|
678
|
+
message
|
|
679
|
+
});
|
|
680
|
+
return {
|
|
681
|
+
...signatureParams,
|
|
682
|
+
functionName,
|
|
683
|
+
functionSignature: handlerIface.encodeFunctionData(
|
|
684
|
+
// remove params in brackets from string
|
|
685
|
+
functionName.replace(/\(([^)]*)\)[^(]*$/, ""), [args.exchangeId])
|
|
686
|
+
};
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
export async function relayMetaTransaction(args) {
|
|
690
|
+
const { chainId, contractAddress, metaTx } = args;
|
|
691
|
+
const biconomy = new Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
692
|
+
const relayTxResponse = await biconomy.relayTransaction({
|
|
693
|
+
to: contractAddress,
|
|
694
|
+
params: [
|
|
695
|
+
metaTx.params.userAddress,
|
|
696
|
+
metaTx.params.functionName,
|
|
697
|
+
metaTx.params.functionSignature,
|
|
698
|
+
metaTx.params.nonce,
|
|
699
|
+
metaTx.params.sigR,
|
|
700
|
+
metaTx.params.sigS,
|
|
701
|
+
metaTx.params.sigV
|
|
702
|
+
],
|
|
703
|
+
from: metaTx.params.userAddress
|
|
704
|
+
});
|
|
705
|
+
return {
|
|
706
|
+
wait: async () => {
|
|
707
|
+
const waitResponse = await biconomy.wait({
|
|
708
|
+
networkId: chainId,
|
|
709
|
+
transactionHash: relayTxResponse.txHash
|
|
710
|
+
});
|
|
711
|
+
const txHash = waitResponse.data.newHash;
|
|
712
|
+
const txReceipt = await args.web3LibAdapter.getTransactionReceipt(txHash);
|
|
713
|
+
console.log("[relayBiconomyMetaTransaction.wait] txReceipt", txReceipt);
|
|
714
|
+
return {
|
|
715
|
+
to: txReceipt?.to || contractAddress,
|
|
716
|
+
from: txReceipt?.from || metaTx.params.userAddress,
|
|
717
|
+
transactionHash: txHash,
|
|
718
|
+
logs: txReceipt?.logs || [],
|
|
719
|
+
effectiveGasPrice: BigNumber.from(waitResponse.data.newGasPrice)
|
|
720
|
+
};
|
|
721
|
+
},
|
|
722
|
+
hash: relayTxResponse.txHash
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
export async function getResubmitted(args) {
|
|
726
|
+
const { chainId, metaTx } = args;
|
|
727
|
+
const biconomy = new Biconomy(metaTx.config.relayerUrl, metaTx.config.apiKey, metaTx.config.apiId);
|
|
728
|
+
const retriedHashesResponse = await biconomy.getResubmitted({
|
|
729
|
+
networkId: chainId,
|
|
730
|
+
transactionHash: metaTx.originalHash
|
|
731
|
+
});
|
|
732
|
+
return retriedHashesResponse.data;
|
|
733
|
+
}
|
|
734
734
|
//# sourceMappingURL=handler.js.map
|