@bosonprotocol/core-sdk 1.25.0-alpha.19 → 1.25.0-alpha.20
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/dist/cjs/forwarder/handler.d.ts +1 -1
- package/dist/cjs/forwarder/handler.d.ts.map +1 -1
- package/dist/cjs/forwarder/handler.js +2 -4
- package/dist/cjs/forwarder/handler.js.map +1 -1
- package/dist/cjs/meta-tx/biconomy.d.ts +17 -3
- package/dist/cjs/meta-tx/biconomy.d.ts.map +1 -1
- package/dist/cjs/meta-tx/biconomy.js +19 -0
- package/dist/cjs/meta-tx/biconomy.js.map +1 -1
- package/dist/cjs/meta-tx/handler.d.ts +15 -6
- package/dist/cjs/meta-tx/handler.d.ts.map +1 -1
- package/dist/cjs/meta-tx/handler.js +49 -23
- package/dist/cjs/meta-tx/handler.js.map +1 -1
- package/dist/cjs/meta-tx/mixin.d.ts +4 -4
- package/dist/cjs/meta-tx/mixin.d.ts.map +1 -1
- package/dist/cjs/meta-tx/mixin.js +8 -42
- package/dist/cjs/meta-tx/mixin.js.map +1 -1
- package/dist/cjs/voucher/handler.d.ts +9 -0
- package/dist/cjs/voucher/handler.d.ts.map +1 -1
- package/dist/cjs/voucher/handler.js +21 -1
- package/dist/cjs/voucher/handler.js.map +1 -1
- package/dist/cjs/voucher/interface.d.ts +4 -0
- package/dist/cjs/voucher/interface.d.ts.map +1 -1
- package/dist/cjs/voucher/interface.js +57 -1
- package/dist/cjs/voucher/interface.js.map +1 -1
- package/dist/esm/forwarder/handler.d.ts +1 -1
- package/dist/esm/forwarder/handler.d.ts.map +1 -1
- package/dist/esm/forwarder/handler.js +2 -4
- package/dist/esm/forwarder/handler.js.map +1 -1
- package/dist/esm/meta-tx/biconomy.d.ts +17 -3
- package/dist/esm/meta-tx/biconomy.d.ts.map +1 -1
- package/dist/esm/meta-tx/biconomy.js +17 -0
- package/dist/esm/meta-tx/biconomy.js.map +1 -1
- package/dist/esm/meta-tx/handler.d.ts +15 -6
- package/dist/esm/meta-tx/handler.d.ts.map +1 -1
- package/dist/esm/meta-tx/handler.js +62 -16
- package/dist/esm/meta-tx/handler.js.map +1 -1
- package/dist/esm/meta-tx/mixin.d.ts +4 -4
- package/dist/esm/meta-tx/mixin.d.ts.map +1 -1
- package/dist/esm/meta-tx/mixin.js +4 -34
- package/dist/esm/meta-tx/mixin.js.map +1 -1
- package/dist/esm/voucher/handler.d.ts +9 -0
- package/dist/esm/voucher/handler.d.ts.map +1 -1
- package/dist/esm/voucher/handler.js +15 -1
- package/dist/esm/voucher/handler.js.map +1 -1
- package/dist/esm/voucher/interface.d.ts +4 -0
- package/dist/esm/voucher/interface.d.ts.map +1 -1
- package/dist/esm/voucher/interface.js +52 -0
- package/dist/esm/voucher/interface.js.map +1 -1
- package/package.json +3 -3
- package/src/forwarder/handler.ts +3 -5
- package/src/meta-tx/biconomy.ts +35 -2
- package/src/meta-tx/handler.ts +89 -23
- package/src/meta-tx/mixin.ts +8 -34
- package/src/voucher/handler.ts +27 -0
- package/src/voucher/interface.ts +61 -0
|
@@ -62,4 +62,56 @@ export function encodeWithdrawToProtocol(tokenList) {
|
|
|
62
62
|
tokenList
|
|
63
63
|
]);
|
|
64
64
|
}
|
|
65
|
+
const ownableIface = new Interface([
|
|
66
|
+
{
|
|
67
|
+
inputs: [],
|
|
68
|
+
name: "owner",
|
|
69
|
+
outputs: [
|
|
70
|
+
{
|
|
71
|
+
internalType: "address",
|
|
72
|
+
name: "",
|
|
73
|
+
type: "address"
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
stateMutability: "view",
|
|
77
|
+
type: "function"
|
|
78
|
+
}
|
|
79
|
+
]);
|
|
80
|
+
export function encodeOwner() {
|
|
81
|
+
return ownableIface.encodeFunctionData("owner");
|
|
82
|
+
}
|
|
83
|
+
export function decodeOwner(result) {
|
|
84
|
+
const [owner] = ownableIface.decodeFunctionResult("owner", result);
|
|
85
|
+
return owner;
|
|
86
|
+
}
|
|
87
|
+
const eRC2771ContextIface = new Interface([
|
|
88
|
+
{
|
|
89
|
+
inputs: [
|
|
90
|
+
{
|
|
91
|
+
internalType: "address",
|
|
92
|
+
name: "forwarder",
|
|
93
|
+
type: "address"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
name: "isTrustedForwarder",
|
|
97
|
+
outputs: [
|
|
98
|
+
{
|
|
99
|
+
internalType: "bool",
|
|
100
|
+
name: "",
|
|
101
|
+
type: "bool"
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
stateMutability: "view",
|
|
105
|
+
type: "function"
|
|
106
|
+
}
|
|
107
|
+
]);
|
|
108
|
+
export function encodeIsTrustedForwarder(forwarder) {
|
|
109
|
+
return eRC2771ContextIface.encodeFunctionData("isTrustedForwarder", [
|
|
110
|
+
forwarder
|
|
111
|
+
]);
|
|
112
|
+
}
|
|
113
|
+
export function decodeIsTrustedForwarder(result) {
|
|
114
|
+
const [isTrustedForwarder] = eRC2771ContextIface.decodeFunctionResult("isTrustedForwarder", result);
|
|
115
|
+
return isTrustedForwarder;
|
|
116
|
+
}
|
|
65
117
|
//# sourceMappingURL=interface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/voucher/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;AAEtE,MAAM,UAAU,2BAA2B,CAAC,OAAqB;IAC/D,OAAO,iBAAiB,CAAC,kBAAkB,CAAC,uBAAuB,EAAE;QACnE,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAqB;IAC9D,OAAO,iBAAiB,CAAC,kBAAkB,CAAC,sBAAs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BAAmB,CAAC,oBAAoB,CACnE,oBAAoB,EACpB,MAAM,CACP,CAAC;IACF,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bosonprotocol/core-sdk",
|
|
3
|
-
"version": "1.25.0-alpha.
|
|
3
|
+
"version": "1.25.0-alpha.20",
|
|
4
4
|
"description": "Facilitates interaction with the contracts and subgraphs of the Boson Protocol",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@bosonprotocol/common": "^1.21.0-alpha.
|
|
36
|
+
"@bosonprotocol/common": "^1.21.0-alpha.20",
|
|
37
37
|
"@ethersproject/abi": "^5.5.0",
|
|
38
38
|
"@ethersproject/address": "^5.5.0",
|
|
39
39
|
"@ethersproject/bignumber": "^5.5.0",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"ts-jest": "^27.1.3",
|
|
55
55
|
"typescript": "^4.5.5"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "afdb1457d2c904f3748db41f5af8436ae1f049c1"
|
|
58
58
|
}
|
package/src/forwarder/handler.ts
CHANGED
|
@@ -7,13 +7,13 @@ export async function getNonce(args: {
|
|
|
7
7
|
contractAddress: string;
|
|
8
8
|
user: string;
|
|
9
9
|
web3Lib: Web3LibAdapter;
|
|
10
|
-
batchId
|
|
10
|
+
batchId?: BigNumberish;
|
|
11
11
|
forwarderAbi: typeof abis.MockForwarderABI | typeof abis.BiconomyForwarderABI;
|
|
12
12
|
}): Promise<string> {
|
|
13
13
|
const isMock = args.forwarderAbi === mockInterface.abi;
|
|
14
14
|
const data = isMock
|
|
15
15
|
? mockInterface.encodeGetNonce(args.user)
|
|
16
|
-
: biconomyInterface.encodeGetNonce(args.user, args.batchId);
|
|
16
|
+
: biconomyInterface.encodeGetNonce(args.user, args.batchId || "0");
|
|
17
17
|
|
|
18
18
|
const result = await args.web3Lib.call({
|
|
19
19
|
to: args.contractAddress,
|
|
@@ -45,12 +45,10 @@ export async function verifyEIP712(args: {
|
|
|
45
45
|
args.signature
|
|
46
46
|
);
|
|
47
47
|
try {
|
|
48
|
-
|
|
48
|
+
await args.web3Lib.call({
|
|
49
49
|
to: args.contractAddress,
|
|
50
50
|
data
|
|
51
51
|
});
|
|
52
|
-
const ret = biconomyInterface.decodeVerifyEIP712(result);
|
|
53
|
-
console.log({ ret });
|
|
54
52
|
return true;
|
|
55
53
|
} catch (e) {
|
|
56
54
|
return false;
|
package/src/meta-tx/biconomy.ts
CHANGED
|
@@ -44,13 +44,46 @@ export type GetRetriedHashesArgs = {
|
|
|
44
44
|
transactionHash: string;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
export type ForwarderDomainData = {
|
|
48
|
+
name: string;
|
|
49
|
+
version: string;
|
|
50
|
+
verifyingContract: string;
|
|
51
|
+
salt: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
47
54
|
export class Biconomy {
|
|
48
55
|
public constructor(
|
|
49
56
|
private _relayerUrl: string,
|
|
50
|
-
private _apiKey
|
|
51
|
-
private _apiId
|
|
57
|
+
private _apiKey?: string,
|
|
58
|
+
private _apiId?: string
|
|
52
59
|
) {}
|
|
53
60
|
|
|
61
|
+
public async getForwarderDomainDetails(
|
|
62
|
+
args: { chainId: number },
|
|
63
|
+
overrides: Partial<{
|
|
64
|
+
relayerUrl: string;
|
|
65
|
+
forwarderAddress: string;
|
|
66
|
+
}> = {}
|
|
67
|
+
): Promise<{ [key: string]: ForwarderDomainData }> {
|
|
68
|
+
const url = `${
|
|
69
|
+
overrides.relayerUrl || this._relayerUrl
|
|
70
|
+
}/api/v2/meta-tx/systemInfo?networkId=${args.chainId}`;
|
|
71
|
+
const response = await fetch(url, { method: "GET" });
|
|
72
|
+
|
|
73
|
+
if (!response.ok) {
|
|
74
|
+
let message;
|
|
75
|
+
try {
|
|
76
|
+
const jsonResponse = await response.json();
|
|
77
|
+
message = JSON.stringify(jsonResponse);
|
|
78
|
+
} catch {
|
|
79
|
+
message = response.statusText;
|
|
80
|
+
}
|
|
81
|
+
throw new ApiError(response.status, `Failed to relay tx: ${message}`);
|
|
82
|
+
}
|
|
83
|
+
const txResponse = await response.json();
|
|
84
|
+
return txResponse?.forwarderDomainDetails;
|
|
85
|
+
}
|
|
86
|
+
|
|
54
87
|
public async relayTransaction(
|
|
55
88
|
args: RelayTransactionArgs,
|
|
56
89
|
overrides: Partial<RelayOverrides> = {}
|
package/src/meta-tx/handler.ts
CHANGED
|
@@ -30,7 +30,11 @@ import {
|
|
|
30
30
|
encodeReserveRange
|
|
31
31
|
} from "../offers/interface";
|
|
32
32
|
import { prepareDataSignatureParameters } from "../utils/signature";
|
|
33
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
Biconomy,
|
|
35
|
+
ForwarderDomainData,
|
|
36
|
+
GetRetriedHashesData
|
|
37
|
+
} from "./biconomy";
|
|
34
38
|
import { isAddress } from "@ethersproject/address";
|
|
35
39
|
import { AddressZero } from "@ethersproject/constants";
|
|
36
40
|
import { encodeDepositFunds, encodeWithdrawFunds } from "../funds/interface";
|
|
@@ -48,8 +52,9 @@ import { keccak256 } from "@ethersproject/keccak256";
|
|
|
48
52
|
import { id } from "@ethersproject/hash";
|
|
49
53
|
import { defaultAbiCoder } from "@ethersproject/abi";
|
|
50
54
|
import { ERC20ForwardRequest } from "../forwarder/biconomy-interface";
|
|
51
|
-
import { verifyEIP712 } from "../forwarder/handler";
|
|
55
|
+
import { getNonce, verifyEIP712 } from "../forwarder/handler";
|
|
52
56
|
import { MockForwardRequest } from "../forwarder/mock-interface";
|
|
57
|
+
import { isTrustedForwarder, owner } from "../voucher/handler";
|
|
53
58
|
|
|
54
59
|
export type BaseMetaTxArgs = {
|
|
55
60
|
web3Lib: Web3LibAdapter;
|
|
@@ -60,9 +65,7 @@ export type BaseMetaTxArgs = {
|
|
|
60
65
|
|
|
61
66
|
export type BaseVoucherMetaTxArgs = {
|
|
62
67
|
web3Lib: Web3LibAdapter;
|
|
63
|
-
nonce: BigNumberish;
|
|
64
68
|
bosonVoucherAddress: string;
|
|
65
|
-
forwarderAddress: string;
|
|
66
69
|
chainId: number;
|
|
67
70
|
};
|
|
68
71
|
|
|
@@ -126,7 +129,9 @@ export async function signMetaTx(
|
|
|
126
129
|
|
|
127
130
|
export async function signVoucherMetaTx(
|
|
128
131
|
args: BaseVoucherMetaTxArgs & {
|
|
132
|
+
forwarderAbi: typeof abis.MockForwarderABI;
|
|
129
133
|
functionSignature: string;
|
|
134
|
+
forwarderAddress: string;
|
|
130
135
|
}
|
|
131
136
|
): Promise<SignedVoucherMetaTx> {
|
|
132
137
|
const forwardType = [
|
|
@@ -148,11 +153,17 @@ export async function signVoucherMetaTx(
|
|
|
148
153
|
|
|
149
154
|
const signerAddress = await args.web3Lib.getSignerAddress();
|
|
150
155
|
const chainId = await args.web3Lib.getChainId();
|
|
156
|
+
const nonce = await getNonce({
|
|
157
|
+
contractAddress: args.forwarderAddress,
|
|
158
|
+
user: signerAddress,
|
|
159
|
+
web3Lib: args.web3Lib,
|
|
160
|
+
forwarderAbi: args.forwarderAbi
|
|
161
|
+
});
|
|
151
162
|
|
|
152
163
|
const message = {
|
|
153
164
|
from: signerAddress,
|
|
154
165
|
to: args.bosonVoucherAddress,
|
|
155
|
-
nonce
|
|
166
|
+
nonce,
|
|
156
167
|
data: args.functionSignature
|
|
157
168
|
};
|
|
158
169
|
|
|
@@ -186,6 +197,7 @@ export async function signBiconomyVoucherMetaTx(
|
|
|
186
197
|
| typeof abis.MockForwarderABI
|
|
187
198
|
| typeof abis.BiconomyForwarderABI;
|
|
188
199
|
txGas: BigNumberish;
|
|
200
|
+
relayerUrl: string;
|
|
189
201
|
}
|
|
190
202
|
): Promise<SignedVoucherMetaTx> {
|
|
191
203
|
const customSignatureType = {
|
|
@@ -213,6 +225,43 @@ export async function signBiconomyVoucherMetaTx(
|
|
|
213
225
|
const signerAddress = await args.web3Lib.getSignerAddress();
|
|
214
226
|
const chainId = await args.web3Lib.getChainId();
|
|
215
227
|
|
|
228
|
+
// Check which forwarder needs to be used for the contract
|
|
229
|
+
const biconomyForwarderDomainDetails = await new Biconomy(
|
|
230
|
+
args.relayerUrl
|
|
231
|
+
).getForwarderDomainDetails({ chainId });
|
|
232
|
+
|
|
233
|
+
const biconomyForwarderDomainData = await new Promise<
|
|
234
|
+
ForwarderDomainData | undefined
|
|
235
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
236
|
+
>(async (resolve, reject) => {
|
|
237
|
+
try {
|
|
238
|
+
for (const bFDD of Object.values(biconomyForwarderDomainDetails)) {
|
|
239
|
+
const ret = await isTrustedForwarder({
|
|
240
|
+
forwarder: bFDD.verifyingContract,
|
|
241
|
+
contractAddress: args.bosonVoucherAddress,
|
|
242
|
+
web3Lib: args.web3Lib
|
|
243
|
+
});
|
|
244
|
+
if (ret) {
|
|
245
|
+
resolve(bFDD);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
resolve(undefined);
|
|
249
|
+
} catch (e) {
|
|
250
|
+
reject(e);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
if (!biconomyForwarderDomainData) {
|
|
254
|
+
throw `Unable to find the trusted forwarder for BosonVoucher contract ${args.bosonVoucherAddress}`;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const nonce = await getNonce({
|
|
258
|
+
contractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
259
|
+
user: signerAddress,
|
|
260
|
+
web3Lib: args.web3Lib,
|
|
261
|
+
batchId: args.batchId,
|
|
262
|
+
forwarderAbi: args.forwarderAbi
|
|
263
|
+
});
|
|
264
|
+
|
|
216
265
|
const message = {
|
|
217
266
|
from: signerAddress,
|
|
218
267
|
to: args.bosonVoucherAddress,
|
|
@@ -220,22 +269,15 @@ export async function signBiconomyVoucherMetaTx(
|
|
|
220
269
|
txGas: args.txGas,
|
|
221
270
|
tokenGasPrice: "0",
|
|
222
271
|
batchId: args.batchId,
|
|
223
|
-
batchNonce:
|
|
272
|
+
batchNonce: nonce,
|
|
224
273
|
deadline: Math.floor(Date.now() / 1000 + 3600),
|
|
225
274
|
data: args.functionSignature
|
|
226
275
|
};
|
|
227
276
|
|
|
228
|
-
const biconomyForwarderDomainData = {
|
|
229
|
-
name: "Biconomy Forwarder",
|
|
230
|
-
version: "1",
|
|
231
|
-
verifyingContract: args.forwarderAddress,
|
|
232
|
-
salt: hexZeroPad(BigNumber.from(chainId).toHexString(), 32)
|
|
233
|
-
};
|
|
234
|
-
|
|
235
277
|
const signatureParams = await prepareDataSignatureParameters({
|
|
236
278
|
...args,
|
|
237
279
|
chainId,
|
|
238
|
-
verifyingContractAddress:
|
|
280
|
+
verifyingContractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
239
281
|
customSignatureType,
|
|
240
282
|
primaryType: "ERC20ForwardRequest",
|
|
241
283
|
message,
|
|
@@ -268,7 +310,7 @@ export async function signBiconomyVoucherMetaTx(
|
|
|
268
310
|
// verify signature
|
|
269
311
|
const signatureVerified = await verifyEIP712({
|
|
270
312
|
request: message,
|
|
271
|
-
contractAddress:
|
|
313
|
+
contractAddress: biconomyForwarderDomainData.verifyingContract,
|
|
272
314
|
web3Lib: args.web3Lib,
|
|
273
315
|
domainSeparator,
|
|
274
316
|
forwarderAbi: args.forwarderAbi,
|
|
@@ -573,10 +615,12 @@ export async function signMetaTxPreMint(
|
|
|
573
615
|
args: BaseVoucherMetaTxArgs & {
|
|
574
616
|
offerId: BigNumberish;
|
|
575
617
|
amount: BigNumberish;
|
|
576
|
-
batchId
|
|
618
|
+
batchId?: BigNumberish;
|
|
619
|
+
forwarderAddress?: string;
|
|
577
620
|
forwarderAbi:
|
|
578
621
|
| typeof abis.MockForwarderABI
|
|
579
622
|
| typeof abis.BiconomyForwarderABI;
|
|
623
|
+
relayerUrl: string;
|
|
580
624
|
}
|
|
581
625
|
): Promise<SignedVoucherMetaTx> {
|
|
582
626
|
const localConfig = defaultConfigs.find(
|
|
@@ -587,13 +631,17 @@ export async function signMetaTxPreMint(
|
|
|
587
631
|
if (isLocal) {
|
|
588
632
|
return signVoucherMetaTx({
|
|
589
633
|
...args,
|
|
590
|
-
|
|
634
|
+
forwarderAddress: args.forwarderAddress,
|
|
635
|
+
functionSignature,
|
|
636
|
+
forwarderAbi: args.forwarderAbi as typeof abis.MockForwarderABI
|
|
591
637
|
});
|
|
592
638
|
}
|
|
593
639
|
const txGas = 200000 + BigNumber.from(args.amount).mul(2500).toNumber(); // ~(180000 + 2250*N) estimation on 2023/02/03
|
|
594
640
|
return signBiconomyVoucherMetaTx({
|
|
595
641
|
...args,
|
|
596
642
|
functionSignature,
|
|
643
|
+
forwarderAbi: args.forwarderAbi as typeof abis.BiconomyForwarderABI,
|
|
644
|
+
batchId: args.batchId || "0",
|
|
597
645
|
txGas
|
|
598
646
|
});
|
|
599
647
|
}
|
|
@@ -602,10 +650,12 @@ export async function signMetaTxSetApprovalForAll(
|
|
|
602
650
|
args: BaseVoucherMetaTxArgs & {
|
|
603
651
|
operator: string;
|
|
604
652
|
approved: boolean;
|
|
605
|
-
batchId
|
|
653
|
+
batchId?: BigNumberish;
|
|
654
|
+
forwarderAddress?: string;
|
|
606
655
|
forwarderAbi:
|
|
607
656
|
| typeof abis.MockForwarderABI
|
|
608
657
|
| typeof abis.BiconomyForwarderABI;
|
|
658
|
+
relayerUrl: string;
|
|
609
659
|
}
|
|
610
660
|
): Promise<SignedVoucherMetaTx> {
|
|
611
661
|
const localConfig = defaultConfigs.find(
|
|
@@ -619,13 +669,17 @@ export async function signMetaTxSetApprovalForAll(
|
|
|
619
669
|
if (isLocal) {
|
|
620
670
|
return signVoucherMetaTx({
|
|
621
671
|
...args,
|
|
622
|
-
|
|
672
|
+
forwarderAddress: args.forwarderAddress,
|
|
673
|
+
functionSignature,
|
|
674
|
+
forwarderAbi: args.forwarderAbi as typeof abis.MockForwarderABI
|
|
623
675
|
});
|
|
624
676
|
}
|
|
625
677
|
const txGas = 100000; // ~70000 estimation on 2023/02/03
|
|
626
678
|
return signBiconomyVoucherMetaTx({
|
|
627
679
|
...args,
|
|
628
680
|
functionSignature,
|
|
681
|
+
forwarderAbi: args.forwarderAbi as typeof abis.BiconomyForwarderABI,
|
|
682
|
+
batchId: args.batchId || "0",
|
|
629
683
|
txGas
|
|
630
684
|
});
|
|
631
685
|
}
|
|
@@ -634,10 +688,12 @@ export async function signMetaTxSetApprovalForAllToContract(
|
|
|
634
688
|
args: BaseVoucherMetaTxArgs & {
|
|
635
689
|
operator: string;
|
|
636
690
|
approved: boolean;
|
|
637
|
-
batchId
|
|
691
|
+
batchId?: BigNumberish;
|
|
692
|
+
forwarderAddress?: string;
|
|
638
693
|
forwarderAbi:
|
|
639
694
|
| typeof abis.MockForwarderABI
|
|
640
695
|
| typeof abis.BiconomyForwarderABI;
|
|
696
|
+
relayerUrl: string;
|
|
641
697
|
},
|
|
642
698
|
overrides: {
|
|
643
699
|
txGas?: number;
|
|
@@ -654,13 +710,17 @@ export async function signMetaTxSetApprovalForAllToContract(
|
|
|
654
710
|
if (isLocal) {
|
|
655
711
|
return signVoucherMetaTx({
|
|
656
712
|
...args,
|
|
657
|
-
|
|
713
|
+
forwarderAddress: args.forwarderAddress,
|
|
714
|
+
functionSignature,
|
|
715
|
+
forwarderAbi: args.forwarderAbi as typeof abis.MockForwarderABI
|
|
658
716
|
});
|
|
659
717
|
}
|
|
660
718
|
const txGas = overrides.txGas || 100000; // TODO: estimate the gas needed
|
|
661
719
|
return signBiconomyVoucherMetaTx({
|
|
662
720
|
...args,
|
|
663
721
|
functionSignature,
|
|
722
|
+
forwarderAbi: args.forwarderAbi as typeof abis.BiconomyForwarderABI,
|
|
723
|
+
batchId: args.batchId || "0",
|
|
664
724
|
txGas
|
|
665
725
|
});
|
|
666
726
|
}
|
|
@@ -669,10 +729,12 @@ export async function signMetaTxCallExternalContract(
|
|
|
669
729
|
args: BaseVoucherMetaTxArgs & {
|
|
670
730
|
to: string;
|
|
671
731
|
data: string;
|
|
672
|
-
batchId
|
|
732
|
+
batchId?: BigNumberish;
|
|
733
|
+
forwarderAddress?: string;
|
|
673
734
|
forwarderAbi:
|
|
674
735
|
| typeof abis.MockForwarderABI
|
|
675
736
|
| typeof abis.BiconomyForwarderABI;
|
|
737
|
+
relayerUrl: string;
|
|
676
738
|
},
|
|
677
739
|
overrides: {
|
|
678
740
|
txGas?: number;
|
|
@@ -686,13 +748,17 @@ export async function signMetaTxCallExternalContract(
|
|
|
686
748
|
if (isLocal) {
|
|
687
749
|
return signVoucherMetaTx({
|
|
688
750
|
...args,
|
|
689
|
-
|
|
751
|
+
forwarderAddress: args.forwarderAddress,
|
|
752
|
+
functionSignature,
|
|
753
|
+
forwarderAbi: args.forwarderAbi as typeof abis.MockForwarderABI
|
|
690
754
|
});
|
|
691
755
|
}
|
|
692
756
|
const txGas = overrides.txGas || 500000; // TODO: estimate the gas needed
|
|
693
757
|
return signBiconomyVoucherMetaTx({
|
|
694
758
|
...args,
|
|
695
759
|
functionSignature,
|
|
760
|
+
forwarderAbi: args.forwarderAbi as typeof abis.BiconomyForwarderABI,
|
|
761
|
+
batchId: args.batchId || "0",
|
|
696
762
|
txGas
|
|
697
763
|
});
|
|
698
764
|
}
|
package/src/meta-tx/mixin.ts
CHANGED
|
@@ -165,25 +165,17 @@ export class MetaTxMixin extends BaseCoreSDK {
|
|
|
165
165
|
| "web3Lib"
|
|
166
166
|
| "bosonVoucherAddress"
|
|
167
167
|
| "chainId"
|
|
168
|
-
| "nonce"
|
|
169
168
|
| "forwarderAddress"
|
|
170
169
|
| "batchId"
|
|
171
170
|
| "forwarderAbi"
|
|
171
|
+
| "relayerUrl"
|
|
172
172
|
>,
|
|
173
173
|
overrides: Partial<{
|
|
174
174
|
batchId: BigNumberish;
|
|
175
175
|
}> = {}
|
|
176
176
|
) {
|
|
177
|
-
const signerAddress = await this._web3Lib.getSignerAddress();
|
|
178
177
|
const forwarderAddress = this._contracts.forwarder;
|
|
179
178
|
const batchId = overrides.batchId || 0;
|
|
180
|
-
const nonce = await getNonce({
|
|
181
|
-
contractAddress: forwarderAddress,
|
|
182
|
-
user: signerAddress,
|
|
183
|
-
web3Lib: this._web3Lib,
|
|
184
|
-
batchId,
|
|
185
|
-
forwarderAbi: this._metaTxConfig.forwarderAbi
|
|
186
|
-
});
|
|
187
179
|
const offerFromSubgraph = await getOfferById(
|
|
188
180
|
this._subgraphUrl,
|
|
189
181
|
args.offerId
|
|
@@ -192,10 +184,10 @@ export class MetaTxMixin extends BaseCoreSDK {
|
|
|
192
184
|
web3Lib: this._web3Lib,
|
|
193
185
|
bosonVoucherAddress: offerFromSubgraph.seller.voucherCloneAddress,
|
|
194
186
|
chainId: this._chainId,
|
|
195
|
-
nonce,
|
|
196
187
|
forwarderAddress,
|
|
197
188
|
batchId,
|
|
198
189
|
forwarderAbi: this._metaTxConfig.forwarderAbi,
|
|
190
|
+
relayerUrl: this._metaTxConfig.relayerUrl,
|
|
199
191
|
...args
|
|
200
192
|
});
|
|
201
193
|
}
|
|
@@ -210,6 +202,7 @@ export class MetaTxMixin extends BaseCoreSDK {
|
|
|
210
202
|
| "forwarderAddress"
|
|
211
203
|
| "batchId"
|
|
212
204
|
| "forwarderAbi"
|
|
205
|
+
| "relayerUrl"
|
|
213
206
|
>,
|
|
214
207
|
overrides: Partial<{
|
|
215
208
|
batchId: BigNumberish;
|
|
@@ -222,22 +215,15 @@ export class MetaTxMixin extends BaseCoreSDK {
|
|
|
222
215
|
);
|
|
223
216
|
const forwarderAddress = this._contracts.forwarder;
|
|
224
217
|
const batchId = overrides.batchId || 0;
|
|
225
|
-
const nonce = await getNonce({
|
|
226
|
-
contractAddress: forwarderAddress,
|
|
227
|
-
user: sellerAddress,
|
|
228
|
-
web3Lib: this._web3Lib,
|
|
229
|
-
batchId,
|
|
230
|
-
forwarderAbi: this._metaTxConfig.forwarderAbi
|
|
231
|
-
});
|
|
232
218
|
|
|
233
219
|
return handler.signMetaTxSetApprovalForAll({
|
|
234
220
|
web3Lib: this._web3Lib,
|
|
235
221
|
bosonVoucherAddress: seller.voucherCloneAddress,
|
|
236
222
|
chainId: this._chainId,
|
|
237
|
-
nonce,
|
|
238
223
|
forwarderAddress,
|
|
239
224
|
batchId,
|
|
240
225
|
forwarderAbi: this._metaTxConfig.forwarderAbi,
|
|
226
|
+
relayerUrl: this._metaTxConfig.relayerUrl,
|
|
241
227
|
...args
|
|
242
228
|
});
|
|
243
229
|
}
|
|
@@ -252,6 +238,7 @@ export class MetaTxMixin extends BaseCoreSDK {
|
|
|
252
238
|
| "forwarderAddress"
|
|
253
239
|
| "batchId"
|
|
254
240
|
| "forwarderAbi"
|
|
241
|
+
| "relayerUrl"
|
|
255
242
|
>,
|
|
256
243
|
overrides: Partial<{
|
|
257
244
|
batchId?: BigNumberish;
|
|
@@ -265,23 +252,16 @@ export class MetaTxMixin extends BaseCoreSDK {
|
|
|
265
252
|
);
|
|
266
253
|
const forwarderAddress = this._contracts.forwarder;
|
|
267
254
|
const batchId = overrides.batchId || 0;
|
|
268
|
-
const nonce = await getNonce({
|
|
269
|
-
contractAddress: forwarderAddress,
|
|
270
|
-
user: sellerAddress,
|
|
271
|
-
web3Lib: this._web3Lib,
|
|
272
|
-
batchId,
|
|
273
|
-
forwarderAbi: this._metaTxConfig.forwarderAbi
|
|
274
|
-
});
|
|
275
255
|
|
|
276
256
|
return handler.signMetaTxSetApprovalForAllToContract(
|
|
277
257
|
{
|
|
278
258
|
web3Lib: this._web3Lib,
|
|
279
259
|
bosonVoucherAddress: seller.voucherCloneAddress,
|
|
280
260
|
chainId: this._chainId,
|
|
281
|
-
nonce,
|
|
282
261
|
forwarderAddress,
|
|
283
262
|
batchId,
|
|
284
263
|
forwarderAbi: this._metaTxConfig.forwarderAbi,
|
|
264
|
+
relayerUrl: this._metaTxConfig.relayerUrl,
|
|
285
265
|
...args
|
|
286
266
|
},
|
|
287
267
|
{
|
|
@@ -300,6 +280,7 @@ export class MetaTxMixin extends BaseCoreSDK {
|
|
|
300
280
|
| "forwarderAddress"
|
|
301
281
|
| "batchId"
|
|
302
282
|
| "forwarderAbi"
|
|
283
|
+
| "relayerUrl"
|
|
303
284
|
>,
|
|
304
285
|
overrides: Partial<{
|
|
305
286
|
batchId?: BigNumberish;
|
|
@@ -313,23 +294,16 @@ export class MetaTxMixin extends BaseCoreSDK {
|
|
|
313
294
|
);
|
|
314
295
|
const forwarderAddress = this._contracts.forwarder;
|
|
315
296
|
const batchId = overrides.batchId || 0;
|
|
316
|
-
const nonce = await getNonce({
|
|
317
|
-
contractAddress: forwarderAddress,
|
|
318
|
-
user: sellerAddress,
|
|
319
|
-
web3Lib: this._web3Lib,
|
|
320
|
-
batchId,
|
|
321
|
-
forwarderAbi: this._metaTxConfig.forwarderAbi
|
|
322
|
-
});
|
|
323
297
|
|
|
324
298
|
return handler.signMetaTxCallExternalContract(
|
|
325
299
|
{
|
|
326
300
|
web3Lib: this._web3Lib,
|
|
327
301
|
bosonVoucherAddress: seller.voucherCloneAddress,
|
|
328
302
|
chainId: this._chainId,
|
|
329
|
-
nonce,
|
|
330
303
|
forwarderAddress,
|
|
331
304
|
batchId,
|
|
332
305
|
forwarderAbi: this._metaTxConfig.forwarderAbi,
|
|
306
|
+
relayerUrl: this._metaTxConfig.relayerUrl,
|
|
333
307
|
...args
|
|
334
308
|
},
|
|
335
309
|
{
|
package/src/voucher/handler.ts
CHANGED
|
@@ -5,11 +5,15 @@ import {
|
|
|
5
5
|
decodeGetAvailablePreMints,
|
|
6
6
|
decodeGetRangeByOfferId,
|
|
7
7
|
decodeIsApprovedForAll,
|
|
8
|
+
decodeIsTrustedForwarder,
|
|
9
|
+
decodeOwner,
|
|
8
10
|
encodeBurnPremintedVouchers,
|
|
9
11
|
encodeCallExternalContract,
|
|
10
12
|
encodeGetAvailablePreMints,
|
|
11
13
|
encodeGetRangeByOfferId,
|
|
12
14
|
encodeIsApprovedForAll,
|
|
15
|
+
encodeIsTrustedForwarder,
|
|
16
|
+
encodeOwner,
|
|
13
17
|
encodePreMint,
|
|
14
18
|
encodeSetApprovalForAllToContract,
|
|
15
19
|
encodeTransferFrom,
|
|
@@ -27,6 +31,29 @@ export async function burnPremintedVouchers(args: {
|
|
|
27
31
|
});
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
export async function owner(args: {
|
|
35
|
+
contractAddress: string;
|
|
36
|
+
web3Lib: Web3LibAdapter;
|
|
37
|
+
}): Promise<string> {
|
|
38
|
+
const result = await args.web3Lib.call({
|
|
39
|
+
to: args.contractAddress,
|
|
40
|
+
data: encodeOwner()
|
|
41
|
+
});
|
|
42
|
+
return decodeOwner(result);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function isTrustedForwarder(args: {
|
|
46
|
+
forwarder: string;
|
|
47
|
+
contractAddress: string;
|
|
48
|
+
web3Lib: Web3LibAdapter;
|
|
49
|
+
}): Promise<boolean> {
|
|
50
|
+
const result = await args.web3Lib.call({
|
|
51
|
+
to: args.contractAddress,
|
|
52
|
+
data: encodeIsTrustedForwarder(args.forwarder)
|
|
53
|
+
});
|
|
54
|
+
return decodeIsTrustedForwarder(result);
|
|
55
|
+
}
|
|
56
|
+
|
|
30
57
|
export async function getAvailablePreMints(args: {
|
|
31
58
|
offerId: BigNumberish;
|
|
32
59
|
contractAddress: string;
|
package/src/voucher/interface.ts
CHANGED
|
@@ -84,3 +84,64 @@ export function encodeWithdrawToProtocol(tokenList: string[]) {
|
|
|
84
84
|
tokenList
|
|
85
85
|
]);
|
|
86
86
|
}
|
|
87
|
+
|
|
88
|
+
const ownableIface = new Interface([
|
|
89
|
+
{
|
|
90
|
+
inputs: [],
|
|
91
|
+
name: "owner",
|
|
92
|
+
outputs: [
|
|
93
|
+
{
|
|
94
|
+
internalType: "address",
|
|
95
|
+
name: "",
|
|
96
|
+
type: "address"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
stateMutability: "view",
|
|
100
|
+
type: "function"
|
|
101
|
+
}
|
|
102
|
+
]);
|
|
103
|
+
|
|
104
|
+
export function encodeOwner() {
|
|
105
|
+
return ownableIface.encodeFunctionData("owner");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function decodeOwner(result: string): string {
|
|
109
|
+
const [owner] = ownableIface.decodeFunctionResult("owner", result);
|
|
110
|
+
return owner;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const eRC2771ContextIface = new Interface([
|
|
114
|
+
{
|
|
115
|
+
inputs: [
|
|
116
|
+
{
|
|
117
|
+
internalType: "address",
|
|
118
|
+
name: "forwarder",
|
|
119
|
+
type: "address"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
name: "isTrustedForwarder",
|
|
123
|
+
outputs: [
|
|
124
|
+
{
|
|
125
|
+
internalType: "bool",
|
|
126
|
+
name: "",
|
|
127
|
+
type: "bool"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
stateMutability: "view",
|
|
131
|
+
type: "function"
|
|
132
|
+
}
|
|
133
|
+
]);
|
|
134
|
+
|
|
135
|
+
export function encodeIsTrustedForwarder(forwarder: string) {
|
|
136
|
+
return eRC2771ContextIface.encodeFunctionData("isTrustedForwarder", [
|
|
137
|
+
forwarder
|
|
138
|
+
]);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function decodeIsTrustedForwarder(result: string): boolean {
|
|
142
|
+
const [isTrustedForwarder] = eRC2771ContextIface.decodeFunctionResult(
|
|
143
|
+
"isTrustedForwarder",
|
|
144
|
+
result
|
|
145
|
+
);
|
|
146
|
+
return isTrustedForwarder;
|
|
147
|
+
}
|