thirdweb 5.64.1 → 5.64.2
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/auth/core/generate-login-payload.js +1 -1
- package/dist/cjs/auth/core/generate-login-payload.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/deploy-vote.js +13 -13
- package/dist/cjs/extensions/prebuilts/deploy-vote.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/auth/core/generate-login-payload.js +1 -1
- package/dist/esm/auth/core/generate-login-payload.js.map +1 -1
- package/dist/esm/extensions/prebuilts/deploy-vote.js +13 -13
- package/dist/esm/extensions/prebuilts/deploy-vote.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/auth/core/generate-login-payload.test.ts +1 -1
- package/src/auth/core/generate-login-payload.ts +1 -1
- package/src/extensions/prebuilts/deploy-vote.test.ts +1 -46
- package/src/extensions/prebuilts/deploy-vote.ts +21 -20
- package/src/extensions/split/split.test.ts +76 -0
- package/src/extensions/vote/{read/proposalExists.test.ts → vote.test.ts} +21 -52
- package/src/version.ts +1 -1
- package/src/wallets/smart/smart-wallet-integration.test.ts +11 -8
- package/src/extensions/prebuilts/deploy-split.test.ts +0 -31
- package/src/extensions/split/read/getAllRecipientsAddresses.test.ts +0 -41
- package/src/extensions/split/read/getAllRecipientsPercentages.test.ts +0 -50
- package/src/extensions/split/read/getRecipientSplitPercentage.test.ts +0 -49
@@ -26,7 +26,7 @@ function generateLoginPayload(options) {
|
|
26
26
|
statement: options.login?.statement || constants_js_1.DEFAULT_LOGIN_STATEMENT,
|
27
27
|
version: options.login?.version || constants_js_1.DEFAULT_LOGIN_VERSION,
|
28
28
|
resources: options.login?.resources,
|
29
|
-
uri: options.login?.uri,
|
29
|
+
uri: options.login?.uri || options.domain,
|
30
30
|
};
|
31
31
|
};
|
32
32
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generate-login-payload.js","sourceRoot":"","sources":["../../../../src/auth/core/generate-login-payload.ts"],"names":[],"mappings":";;AAqBA,oDA8BC;AAnDD,iDAIwB;AAWxB;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,OAAoB;IACvD,OAAO,KAAK,EAAE,EACZ,OAAO,EACP,OAAO,GACoB,EAAyB,EAAE;QACtD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,cAAc,GAClB,CAAC,OAAO,CAAC,KAAK,EAAE,4BAA4B;YAC1C,+CAAgC,CAAC,GAAG,IAAI,CAAC;QAC7C,OAAO;YACL,OAAO;YACP,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;YAClD,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,eAAe,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,cAAc,CAAC,CAAC,WAAW,EAAE;YAC7D,cAAc,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,cAAc,CAAC,CAAC,WAAW,EAAE;YAC5D,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE;YACtC,uEAAuE;YACvE,KAAK,EAAE,MAAM,CACX,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ;gBAC9B,CAAC,GAAG,EAAE,CACJ,qCAAO,uBAAuB,GAAE,IAAI,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAC1D,cAAc,EAAE,CACjB,CAAC,CACL,EAAE;YACH,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS,IAAI,sCAAuB;YAC9D,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,IAAI,oCAAqB;YACxD,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS;YACnC,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG;
|
1
|
+
{"version":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AM;SAC1C,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
@@ -57,6 +57,19 @@ async function deployVoteContract(options) {
|
|
57
57
|
async function getInitializeTransaction(options) {
|
58
58
|
const { client, implementationContract, params, chain } = options;
|
59
59
|
const { name, tokenAddress, initialProposalThreshold, minVoteQuorumRequiredPercent, initialVotingDelay, initialVotingPeriod, description, symbol, image, external_link, social_urls, } = params;
|
60
|
+
// Validate initialVoteQuorumFraction
|
61
|
+
const _num = Number(minVoteQuorumRequiredPercent);
|
62
|
+
if (Number.isNaN(_num)) {
|
63
|
+
throw new Error(`${minVoteQuorumRequiredPercent} is not a valid minVoteQuorumRequiredPercent`);
|
64
|
+
}
|
65
|
+
if (_num < 0 || _num > 100) {
|
66
|
+
throw new Error("minVoteQuorumRequiredPercent must be >= 0 and <= 100");
|
67
|
+
}
|
68
|
+
// Make sure if user is passing a float, it should only have 2 digit after the decimal point
|
69
|
+
if (!Number.isInteger(_num)) {
|
70
|
+
throw new Error(`${_num} is an invalid value. Only integer-like values accepted`);
|
71
|
+
}
|
72
|
+
const initialVoteQuorumFraction = BigInt(_num);
|
60
73
|
const tokenErc20Contract = (0, contract_js_1.getContract)({
|
61
74
|
address: tokenAddress,
|
62
75
|
client,
|
@@ -92,19 +105,6 @@ async function getInitializeTransaction(options) {
|
|
92
105
|
],
|
93
106
|
})) ||
|
94
107
|
"";
|
95
|
-
// Validate initialVoteQuorumFraction
|
96
|
-
const _num = Number(minVoteQuorumRequiredPercent);
|
97
|
-
if (Number.isNaN(_num)) {
|
98
|
-
throw new Error(`${minVoteQuorumRequiredPercent} is not a valid minVoteQuorumRequiredPercent`);
|
99
|
-
}
|
100
|
-
if (_num < 0 || _num > 100) {
|
101
|
-
throw new Error("minVoteQuorumRequiredPercent must be >= 0 and <= 100");
|
102
|
-
}
|
103
|
-
// Make sure if user is passing a float, it should only have 2 digit after the decimal point
|
104
|
-
if (!Number.isInteger(_num)) {
|
105
|
-
throw new Error(`${_num} is an invalid value. Only integer-like values accepted`);
|
106
|
-
}
|
107
|
-
const initialVoteQuorumFraction = BigInt(_num);
|
108
108
|
return initialize({
|
109
109
|
contract: implementationContract,
|
110
110
|
name,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deploy-vote.js","sourceRoot":"","sources":["../../../../src/extensions/prebuilts/deploy-vote.ts"],"names":[],"mappings":";;AA2FA,gDAwBC;AAjHD,4DAAgF;AAChF,mGAA2F;AAC3F,+EAAoG;AAIpG,2DAAqD;AAyDrD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,KAAK,UAAU,kBAAkB,CAAC,OAAkC;IACzE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACnD,MAAM,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,GACpD,MAAM,IAAA,mDAAoC,EAAC;QACzC,KAAK;QACL,MAAM;QACN,OAAO;QACP,UAAU,EAAE,WAAW;KACxB,CAAC,CAAC;IACL,MAAM,qBAAqB,GAAG,MAAM,wBAAwB,CAAC;QAC3D,MAAM;QACN,sBAAsB;QACtB,MAAM;QACN,cAAc,EAAE,OAAO,CAAC,OAAO;QAC/B,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,IAAA,gDAAoB,EAAC;QAC1B,MAAM;QACN,KAAK;QACL,OAAO;QACP,oBAAoB;QACpB,qBAAqB;KACtB,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,wBAAwB,CAAC,OAMvC;IACC,MAAM,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAClE,MAAM,EACJ,IAAI,EACJ,YAAY,EACZ,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,MAAM,EACN,KAAK,EACL,aAAa,EACb,WAAW,GACZ,GAAG,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"deploy-vote.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AAsB;QAChC,IAAI;QACJ,KAAK,EAAE,YAAY;QACnB,2EAA2E;QAC3E,wBAAwB,EAAE,6BAA6B;QACvD,yBAAyB;QACzB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,IAAI,CAAC,CAAC;QACnD,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,CAAC;QAChD,WAAW;QACX,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,IAAI,EAAE;KAClD,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cjs/version.js
CHANGED
@@ -23,7 +23,7 @@ export function generateLoginPayload(options) {
|
|
23
23
|
statement: options.login?.statement || DEFAULT_LOGIN_STATEMENT,
|
24
24
|
version: options.login?.version || DEFAULT_LOGIN_VERSION,
|
25
25
|
resources: options.login?.resources,
|
26
|
-
uri: options.login?.uri,
|
26
|
+
uri: options.login?.uri || options.domain,
|
27
27
|
};
|
28
28
|
};
|
29
29
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generate-login-payload.js","sourceRoot":"","sources":["../../../../src/auth/core/generate-login-payload.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAWxB;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACvD,OAAO,KAAK,EAAE,EACZ,OAAO,EACP,OAAO,GACoB,EAAyB,EAAE;QACtD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,cAAc,GAClB,CAAC,OAAO,CAAC,KAAK,EAAE,4BAA4B;YAC1C,gCAAgC,CAAC,GAAG,IAAI,CAAC;QAC7C,OAAO;YACL,OAAO;YACP,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;YAClD,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,eAAe,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,cAAc,CAAC,CAAC,WAAW,EAAE;YAC7D,cAAc,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,cAAc,CAAC,CAAC,WAAW,EAAE;YAC5D,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE;YACtC,uEAAuE;YACvE,KAAK,EAAE,MAAM,CACX,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ;gBAC9B,CAAC,GAAG,EAAE,CACJ,MAAM,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAC1D,cAAc,EAAE,CACjB,CAAC,CACL,EAAE;YACH,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS,IAAI,uBAAuB;YAC9D,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,IAAI,qBAAqB;YACxD,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS;YACnC,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG;
|
1
|
+
{"version":3,"file":"generate-login-payload.js","sourceRoot":"","sources":["../../../../src/auth/core/generate-login-payload.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAWxB;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAoB;IACvD,OAAO,KAAK,EAAE,EACZ,OAAO,EACP,OAAO,GACoB,EAAyB,EAAE;QACtD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,cAAc,GAClB,CAAC,OAAO,CAAC,KAAK,EAAE,4BAA4B;YAC1C,gCAAgC,CAAC,GAAG,IAAI,CAAC;QAC7C,OAAO;YACL,OAAO;YACP,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;YAClD,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,eAAe,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,cAAc,CAAC,CAAC,WAAW,EAAE;YAC7D,cAAc,EAAE,IAAI,IAAI,CAAC,GAAG,GAAG,cAAc,CAAC,CAAC,WAAW,EAAE;YAC5D,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE;YACtC,uEAAuE;YACvE,KAAK,EAAE,MAAM,CACX,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ;gBAC9B,CAAC,GAAG,EAAE,CACJ,MAAM,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAC1D,cAAc,EAAE,CACjB,CAAC,CACL,EAAE;YACH,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS,IAAI,uBAAuB;YAC9D,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,IAAI,qBAAqB;YACxD,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS;YACnC,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,OAAO,CAAC,MAAM;SAC1C,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
@@ -54,6 +54,19 @@ export async function deployVoteContract(options) {
|
|
54
54
|
async function getInitializeTransaction(options) {
|
55
55
|
const { client, implementationContract, params, chain } = options;
|
56
56
|
const { name, tokenAddress, initialProposalThreshold, minVoteQuorumRequiredPercent, initialVotingDelay, initialVotingPeriod, description, symbol, image, external_link, social_urls, } = params;
|
57
|
+
// Validate initialVoteQuorumFraction
|
58
|
+
const _num = Number(minVoteQuorumRequiredPercent);
|
59
|
+
if (Number.isNaN(_num)) {
|
60
|
+
throw new Error(`${minVoteQuorumRequiredPercent} is not a valid minVoteQuorumRequiredPercent`);
|
61
|
+
}
|
62
|
+
if (_num < 0 || _num > 100) {
|
63
|
+
throw new Error("minVoteQuorumRequiredPercent must be >= 0 and <= 100");
|
64
|
+
}
|
65
|
+
// Make sure if user is passing a float, it should only have 2 digit after the decimal point
|
66
|
+
if (!Number.isInteger(_num)) {
|
67
|
+
throw new Error(`${_num} is an invalid value. Only integer-like values accepted`);
|
68
|
+
}
|
69
|
+
const initialVoteQuorumFraction = BigInt(_num);
|
57
70
|
const tokenErc20Contract = getContract({
|
58
71
|
address: tokenAddress,
|
59
72
|
client,
|
@@ -89,19 +102,6 @@ async function getInitializeTransaction(options) {
|
|
89
102
|
],
|
90
103
|
})) ||
|
91
104
|
"";
|
92
|
-
// Validate initialVoteQuorumFraction
|
93
|
-
const _num = Number(minVoteQuorumRequiredPercent);
|
94
|
-
if (Number.isNaN(_num)) {
|
95
|
-
throw new Error(`${minVoteQuorumRequiredPercent} is not a valid minVoteQuorumRequiredPercent`);
|
96
|
-
}
|
97
|
-
if (_num < 0 || _num > 100) {
|
98
|
-
throw new Error("minVoteQuorumRequiredPercent must be >= 0 and <= 100");
|
99
|
-
}
|
100
|
-
// Make sure if user is passing a float, it should only have 2 digit after the decimal point
|
101
|
-
if (!Number.isInteger(_num)) {
|
102
|
-
throw new Error(`${_num} is an invalid value. Only integer-like values accepted`);
|
103
|
-
}
|
104
|
-
const initialVoteQuorumFraction = BigInt(_num);
|
105
105
|
return initialize({
|
106
106
|
contract: implementationContract,
|
107
107
|
name,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deploy-vote.js","sourceRoot":"","sources":["../../../../src/extensions/prebuilts/deploy-vote.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,EAAE,oCAAoC,EAAE,MAAM,8CAA8C,CAAC;AAIpG,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAyDrD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAkC;IACzE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACnD,MAAM,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,GACpD,MAAM,oCAAoC,CAAC;QACzC,KAAK;QACL,MAAM;QACN,OAAO;QACP,UAAU,EAAE,WAAW;KACxB,CAAC,CAAC;IACL,MAAM,qBAAqB,GAAG,MAAM,wBAAwB,CAAC;QAC3D,MAAM;QACN,sBAAsB;QACtB,MAAM;QACN,cAAc,EAAE,OAAO,CAAC,OAAO;QAC/B,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,oBAAoB,CAAC;QAC1B,MAAM;QACN,KAAK;QACL,OAAO;QACP,oBAAoB;QACpB,qBAAqB;KACtB,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,wBAAwB,CAAC,OAMvC;IACC,MAAM,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAClE,MAAM,EACJ,IAAI,EACJ,YAAY,EACZ,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,MAAM,EACN,KAAK,EACL,aAAa,EACb,WAAW,GACZ,GAAG,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"deploy-vote.js","sourceRoot":"","sources":["../../../../src/extensions/prebuilts/deploy-vote.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,EAAE,oCAAoC,EAAE,MAAM,8CAA8C,CAAC;AAIpG,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAyDrD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAkC;IACzE,MAAM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,WAAW;QACX,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,IAAI,EAAE;KAClD,CAAC,CAAC;AACL,CAAC"}
|
package/dist/esm/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export const version = "5.64.
|
1
|
+
export const version = "5.64.2";
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/dist/types/version.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "5.64.
|
1
|
+
export declare const version = "5.64.2";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
@@ -89,7 +89,7 @@ describe("generateLoginPayload", () => {
|
|
89
89
|
"issued_at": "1970-01-01T00:00:00.000Z",
|
90
90
|
"resources": undefined,
|
91
91
|
"statement": "Please ensure that the domain above matches the URL of the current website.",
|
92
|
-
"uri":
|
92
|
+
"uri": "example.com",
|
93
93
|
"version": "1",
|
94
94
|
}
|
95
95
|
`);
|
@@ -46,7 +46,7 @@ export function generateLoginPayload(options: AuthOptions) {
|
|
46
46
|
statement: options.login?.statement || DEFAULT_LOGIN_STATEMENT,
|
47
47
|
version: options.login?.version || DEFAULT_LOGIN_VERSION,
|
48
48
|
resources: options.login?.resources,
|
49
|
-
uri: options.login?.uri,
|
49
|
+
uri: options.login?.uri || options.domain,
|
50
50
|
};
|
51
51
|
};
|
52
52
|
}
|
@@ -3,57 +3,12 @@ import { ANVIL_CHAIN } from "~test/chains.js";
|
|
3
3
|
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
4
4
|
import { TEST_CLIENT } from "~test/test-clients.js";
|
5
5
|
import { TEST_ACCOUNT_B } from "~test/test-wallets.js";
|
6
|
-
import { isAddress } from "../../utils/address.js";
|
7
|
-
import { deployERC20Contract } from "./deploy-erc20.js";
|
8
6
|
import { deployVoteContract } from "./deploy-vote.js";
|
9
7
|
|
10
8
|
const account = TEST_ACCOUNT_B;
|
11
9
|
|
12
10
|
describe.runIf(process.env.TW_SECRET_KEY)("deploy-voteERC20 contract", () => {
|
13
|
-
it("should deploy Vote contract", async () => {
|
14
|
-
const tokenAddress = await deployERC20Contract({
|
15
|
-
client: TEST_CLIENT,
|
16
|
-
chain: ANVIL_CHAIN,
|
17
|
-
account,
|
18
|
-
type: "TokenERC20",
|
19
|
-
params: {
|
20
|
-
name: "Token",
|
21
|
-
contractURI: TEST_CONTRACT_URI,
|
22
|
-
},
|
23
|
-
});
|
24
|
-
const address = await deployVoteContract({
|
25
|
-
account,
|
26
|
-
client: TEST_CLIENT,
|
27
|
-
chain: ANVIL_CHAIN,
|
28
|
-
params: {
|
29
|
-
name: "",
|
30
|
-
contractURI: TEST_CONTRACT_URI,
|
31
|
-
tokenAddress: tokenAddress,
|
32
|
-
// user needs 0.5 <token> to create proposal
|
33
|
-
initialProposalThreshold: "0.5",
|
34
|
-
// vote expires 10 blocks later
|
35
|
-
initialVotingPeriod: 10,
|
36
|
-
// Requires 51% of users who voted, voted "For", for this proposal to pass
|
37
|
-
minVoteQuorumRequiredPercent: 51,
|
38
|
-
},
|
39
|
-
});
|
40
|
-
expect(address).toBeDefined();
|
41
|
-
expect(isAddress(address)).toBe(true);
|
42
|
-
// Further tests to verify the functionality of this contract
|
43
|
-
// are done in other Vote tests
|
44
|
-
});
|
45
|
-
|
46
11
|
it("should throw if passed an non-integer-like value to minVoteQuorumRequiredPercent", async () => {
|
47
|
-
const tokenAddress = await deployERC20Contract({
|
48
|
-
client: TEST_CLIENT,
|
49
|
-
chain: ANVIL_CHAIN,
|
50
|
-
account,
|
51
|
-
type: "TokenERC20",
|
52
|
-
params: {
|
53
|
-
name: "Token",
|
54
|
-
contractURI: TEST_CONTRACT_URI,
|
55
|
-
},
|
56
|
-
});
|
57
12
|
await expect(() =>
|
58
13
|
deployVoteContract({
|
59
14
|
account,
|
@@ -62,7 +17,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("deploy-voteERC20 contract", () => {
|
|
62
17
|
params: {
|
63
18
|
name: "",
|
64
19
|
contractURI: TEST_CONTRACT_URI,
|
65
|
-
tokenAddress:
|
20
|
+
tokenAddress: "doesnt matter here, code wont be reached",
|
66
21
|
initialProposalThreshold: "0.5",
|
67
22
|
initialVotingPeriod: 10,
|
68
23
|
minVoteQuorumRequiredPercent: 51.12,
|
@@ -136,6 +136,27 @@ async function getInitializeTransaction(options: {
|
|
136
136
|
external_link,
|
137
137
|
social_urls,
|
138
138
|
} = params;
|
139
|
+
|
140
|
+
// Validate initialVoteQuorumFraction
|
141
|
+
const _num = Number(minVoteQuorumRequiredPercent);
|
142
|
+
if (Number.isNaN(_num)) {
|
143
|
+
throw new Error(
|
144
|
+
`${minVoteQuorumRequiredPercent} is not a valid minVoteQuorumRequiredPercent`,
|
145
|
+
);
|
146
|
+
}
|
147
|
+
if (_num < 0 || _num > 100) {
|
148
|
+
throw new Error("minVoteQuorumRequiredPercent must be >= 0 and <= 100");
|
149
|
+
}
|
150
|
+
|
151
|
+
// Make sure if user is passing a float, it should only have 2 digit after the decimal point
|
152
|
+
if (!Number.isInteger(_num)) {
|
153
|
+
throw new Error(
|
154
|
+
`${_num} is an invalid value. Only integer-like values accepted`,
|
155
|
+
);
|
156
|
+
}
|
157
|
+
|
158
|
+
const initialVoteQuorumFraction = BigInt(_num);
|
159
|
+
|
139
160
|
const tokenErc20Contract = getContract({
|
140
161
|
address: tokenAddress,
|
141
162
|
client,
|
@@ -177,26 +198,6 @@ async function getInitializeTransaction(options: {
|
|
177
198
|
})) ||
|
178
199
|
"";
|
179
200
|
|
180
|
-
// Validate initialVoteQuorumFraction
|
181
|
-
const _num = Number(minVoteQuorumRequiredPercent);
|
182
|
-
if (Number.isNaN(_num)) {
|
183
|
-
throw new Error(
|
184
|
-
`${minVoteQuorumRequiredPercent} is not a valid minVoteQuorumRequiredPercent`,
|
185
|
-
);
|
186
|
-
}
|
187
|
-
if (_num < 0 || _num > 100) {
|
188
|
-
throw new Error("minVoteQuorumRequiredPercent must be >= 0 and <= 100");
|
189
|
-
}
|
190
|
-
|
191
|
-
// Make sure if user is passing a float, it should only have 2 digit after the decimal point
|
192
|
-
if (!Number.isInteger(_num)) {
|
193
|
-
throw new Error(
|
194
|
-
`${_num} is an invalid value. Only integer-like values accepted`,
|
195
|
-
);
|
196
|
-
}
|
197
|
-
|
198
|
-
const initialVoteQuorumFraction = BigInt(_num);
|
199
|
-
|
200
201
|
return initialize({
|
201
202
|
contract: implementationContract,
|
202
203
|
name,
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import { beforeAll, describe, expect, it } from "vitest";
|
2
|
+
import { ANVIL_CHAIN } from "~test/chains.js";
|
3
|
+
import { TEST_CLIENT } from "~test/test-clients.js";
|
4
|
+
import { TEST_ACCOUNT_D } from "~test/test-wallets.js";
|
5
|
+
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
6
|
+
import { isAddress } from "../../utils/address.js";
|
7
|
+
import { deploySplitContract } from "../prebuilts/deploy-split.js";
|
8
|
+
import { getAllRecipientsAddresses } from "./read/getAllRecipientsAddresses.js";
|
9
|
+
import { getAllRecipientsPercentages } from "./read/getAllRecipientsPercentages.js";
|
10
|
+
import { getRecipientSplitPercentage } from "./read/getRecipientSplitPercentage.js";
|
11
|
+
|
12
|
+
let contract: ThirdwebContract;
|
13
|
+
const chain = ANVIL_CHAIN;
|
14
|
+
const client = TEST_CLIENT;
|
15
|
+
|
16
|
+
describe.runIf(process.env.TW_SECRET_KEY)("Split contract tests", () => {
|
17
|
+
beforeAll(async () => {
|
18
|
+
const address = await deploySplitContract({
|
19
|
+
account: TEST_ACCOUNT_D,
|
20
|
+
client,
|
21
|
+
chain,
|
22
|
+
params: {
|
23
|
+
name: "split-contract",
|
24
|
+
payees: [
|
25
|
+
"0x12345674b599ce99958242b3D3741e7b01841DF3",
|
26
|
+
"0xA6f11e47dE28B3dB934e945daeb6F538E9019694",
|
27
|
+
],
|
28
|
+
shares: [
|
29
|
+
5100n, // 51%
|
30
|
+
4900n, // 49%
|
31
|
+
],
|
32
|
+
},
|
33
|
+
});
|
34
|
+
expect(address).toBeDefined();
|
35
|
+
expect(isAddress(address)).toBe(true);
|
36
|
+
contract = getContract({
|
37
|
+
address,
|
38
|
+
client,
|
39
|
+
chain,
|
40
|
+
});
|
41
|
+
}, 60_000);
|
42
|
+
|
43
|
+
it("should return all recipient addresses", async () => {
|
44
|
+
const result = await getAllRecipientsAddresses({ contract });
|
45
|
+
expect(result).toStrictEqual([
|
46
|
+
"0x12345674b599ce99958242b3D3741e7b01841DF3",
|
47
|
+
"0xA6f11e47dE28B3dB934e945daeb6F538E9019694",
|
48
|
+
]);
|
49
|
+
});
|
50
|
+
|
51
|
+
it("should return all recipients and their share percentages", async () => {
|
52
|
+
const result = await getAllRecipientsPercentages({ contract });
|
53
|
+
expect(result).toStrictEqual([
|
54
|
+
{
|
55
|
+
address: "0x12345674b599ce99958242b3D3741e7b01841DF3",
|
56
|
+
splitPercentage: 51,
|
57
|
+
},
|
58
|
+
{
|
59
|
+
address: "0xA6f11e47dE28B3dB934e945daeb6F538E9019694",
|
60
|
+
splitPercentage: 49,
|
61
|
+
},
|
62
|
+
]);
|
63
|
+
});
|
64
|
+
|
65
|
+
it("should return split percentage for individual recipient", async () => {
|
66
|
+
const result = await getRecipientSplitPercentage({
|
67
|
+
contract,
|
68
|
+
recipientAddress: "0x12345674b599ce99958242b3D3741e7b01841DF3",
|
69
|
+
});
|
70
|
+
|
71
|
+
expect(result).toStrictEqual({
|
72
|
+
address: "0x12345674b599ce99958242b3D3741e7b01841DF3",
|
73
|
+
splitPercentage: 51,
|
74
|
+
});
|
75
|
+
});
|
76
|
+
});
|
@@ -3,22 +3,22 @@ import { ANVIL_CHAIN } from "~test/chains.js";
|
|
3
3
|
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
4
4
|
import { TEST_CLIENT } from "~test/test-clients.js";
|
5
5
|
import { TEST_ACCOUNT_C } from "~test/test-wallets.js";
|
6
|
-
import { getContract } from "
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
import {
|
11
|
-
import {
|
12
|
-
import { propose } from "
|
13
|
-
import { getAll } from "./getAll.js";
|
14
|
-
import { proposalExists } from "./proposalExists.js";
|
6
|
+
import { getContract } from "../../contract/contract.js";
|
7
|
+
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
|
8
|
+
import { delegate } from "../erc20/__generated__/IVotes/write/delegate.js";
|
9
|
+
import { mintTo } from "../erc20/write/mintTo.js";
|
10
|
+
import { deployERC20Contract } from "../prebuilts/deploy-erc20.js";
|
11
|
+
import { deployVoteContract } from "../prebuilts/deploy-vote.js";
|
12
|
+
import { propose } from "./__generated__/Vote/write/propose.js";
|
13
|
+
import { getAll } from "./read/getAll.js";
|
14
|
+
import { proposalExists } from "./read/proposalExists.js";
|
15
15
|
|
16
16
|
const account = TEST_ACCOUNT_C;
|
17
17
|
const client = TEST_CLIENT;
|
18
18
|
const chain = ANVIL_CHAIN;
|
19
19
|
|
20
20
|
describe.runIf(process.env.TW_SECRET_KEY)("proposal exists", () => {
|
21
|
-
it("
|
21
|
+
it("`proposalExists` and `propose` should work", async () => {
|
22
22
|
const tokenAddress = await deployERC20Contract({
|
23
23
|
client: TEST_CLIENT,
|
24
24
|
chain: ANVIL_CHAIN,
|
@@ -42,47 +42,16 @@ describe.runIf(process.env.TW_SECRET_KEY)("proposal exists", () => {
|
|
42
42
|
minVoteQuorumRequiredPercent: 51,
|
43
43
|
},
|
44
44
|
});
|
45
|
-
|
46
|
-
const contract = getContract({
|
45
|
+
const voteContract = getContract({
|
47
46
|
address,
|
48
47
|
chain,
|
49
48
|
client,
|
50
49
|
});
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
});
|
55
|
-
|
56
|
-
it("should return true if Vote has the proposal (id)", async () => {
|
57
|
-
const tokenAddress = await deployERC20Contract({
|
58
|
-
client: TEST_CLIENT,
|
59
|
-
chain: ANVIL_CHAIN,
|
60
|
-
account,
|
61
|
-
type: "TokenERC20",
|
62
|
-
params: {
|
63
|
-
name: "Token",
|
64
|
-
contractURI: TEST_CONTRACT_URI,
|
65
|
-
},
|
66
|
-
});
|
67
|
-
const address = await deployVoteContract({
|
68
|
-
account,
|
69
|
-
client: TEST_CLIENT,
|
70
|
-
chain: ANVIL_CHAIN,
|
71
|
-
params: {
|
72
|
-
name: "",
|
73
|
-
contractURI: TEST_CONTRACT_URI,
|
74
|
-
tokenAddress: tokenAddress,
|
75
|
-
initialProposalThreshold: "0.5",
|
76
|
-
initialVotingPeriod: 10,
|
77
|
-
minVoteQuorumRequiredPercent: 51,
|
78
|
-
},
|
79
|
-
});
|
80
|
-
|
81
|
-
const contract = getContract({
|
82
|
-
address,
|
83
|
-
chain,
|
84
|
-
client,
|
50
|
+
const result = await proposalExists({
|
51
|
+
contract: voteContract,
|
52
|
+
proposalId: 0n,
|
85
53
|
});
|
54
|
+
expect(result).toBe(false);
|
86
55
|
|
87
56
|
const tokenContract = getContract({
|
88
57
|
address: tokenAddress,
|
@@ -105,19 +74,19 @@ describe.runIf(process.env.TW_SECRET_KEY)("proposal exists", () => {
|
|
105
74
|
|
106
75
|
// step 3: create a proposal
|
107
76
|
const transaction = propose({
|
108
|
-
contract,
|
77
|
+
contract: voteContract,
|
109
78
|
description: "first proposal",
|
110
|
-
targets: [
|
79
|
+
targets: [voteContract.address],
|
111
80
|
values: [0n],
|
112
81
|
calldatas: ["0x"],
|
113
82
|
});
|
114
83
|
await sendAndConfirmTransaction({ transaction, account });
|
115
|
-
const allProposals = await getAll({ contract });
|
84
|
+
const allProposals = await getAll({ contract: voteContract });
|
116
85
|
expect(allProposals.length).toBe(1);
|
117
|
-
const
|
118
|
-
contract,
|
86
|
+
const exists = await proposalExists({
|
87
|
+
contract: voteContract,
|
119
88
|
proposalId: allProposals[0]?.proposalId || -1n,
|
120
89
|
});
|
121
|
-
expect(
|
90
|
+
expect(exists).toBe(true);
|
122
91
|
});
|
123
92
|
});
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.64.
|
1
|
+
export const version = "5.64.2";
|
@@ -20,6 +20,7 @@ import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-co
|
|
20
20
|
import { sendBatchTransaction } from "../../transaction/actions/send-batch-transaction.js";
|
21
21
|
import { waitForReceipt } from "../../transaction/actions/wait-for-tx-receipt.js";
|
22
22
|
import { isContractDeployed } from "../../utils/bytecode/is-contract-deployed.js";
|
23
|
+
import { sleep } from "../../utils/sleep.js";
|
23
24
|
import type { Account, Wallet } from "../interfaces/wallet.js";
|
24
25
|
import { generateAccount } from "../utils/generateAccount.js";
|
25
26
|
import { smartWallet } from "./smart-wallet.js";
|
@@ -332,15 +333,17 @@ describe.runIf(process.env.TW_SECRET_KEY).sequential(
|
|
332
333
|
}),
|
333
334
|
account: newSmartAccount,
|
334
335
|
}),
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
336
|
+
sleep(1000).then(() =>
|
337
|
+
sendAndConfirmTransaction({
|
338
|
+
transaction: claimTo({
|
339
|
+
contract,
|
340
|
+
quantity: 1n,
|
341
|
+
to: newSmartAccount.address,
|
342
|
+
tokenId: 0n,
|
343
|
+
}),
|
344
|
+
account: newSmartAccount,
|
341
345
|
}),
|
342
|
-
|
343
|
-
}),
|
346
|
+
),
|
344
347
|
]);
|
345
348
|
expect(txs.length).toEqual(2);
|
346
349
|
expect(txs.every((t) => t.transactionHash.length === 66)).toBe(true);
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
2
|
-
import { ANVIL_CHAIN } from "~test/chains.js";
|
3
|
-
import { TEST_CLIENT } from "~test/test-clients.js";
|
4
|
-
import { TEST_ACCOUNT_D } from "~test/test-wallets.js";
|
5
|
-
import { isAddress } from "../../utils/address.js";
|
6
|
-
import { deploySplitContract } from "./deploy-split.js";
|
7
|
-
|
8
|
-
describe.runIf(process.env.TW_SECRET_KEY)("deploy-split contract", () => {
|
9
|
-
it("should deploy Split contract", async () => {
|
10
|
-
const address = await deploySplitContract({
|
11
|
-
account: TEST_ACCOUNT_D,
|
12
|
-
client: TEST_CLIENT,
|
13
|
-
chain: ANVIL_CHAIN,
|
14
|
-
params: {
|
15
|
-
name: "split-contract",
|
16
|
-
payees: [
|
17
|
-
"0x12345674b599ce99958242b3D3741e7b01841DF3",
|
18
|
-
"0xA6f11e47dE28B3dB934e945daeb6F538E9019694",
|
19
|
-
],
|
20
|
-
shares: [
|
21
|
-
5100n, // 51%
|
22
|
-
4900n, // 49%
|
23
|
-
],
|
24
|
-
},
|
25
|
-
});
|
26
|
-
expect(address).toBeDefined();
|
27
|
-
expect(isAddress(address)).toBe(true);
|
28
|
-
// Further tests to verify the functionality of this contract
|
29
|
-
// are done in other Split tests
|
30
|
-
});
|
31
|
-
});
|
@@ -1,41 +0,0 @@
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
2
|
-
import { ANVIL_CHAIN } from "~test/chains.js";
|
3
|
-
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
4
|
-
import { TEST_CLIENT } from "~test/test-clients.js";
|
5
|
-
import { TEST_ACCOUNT_C } from "~test/test-wallets.js";
|
6
|
-
import { getContract } from "../../../contract/contract.js";
|
7
|
-
import { deploySplitContract } from "../../../extensions/prebuilts/deploy-split.js";
|
8
|
-
import { getAllRecipientsAddresses } from "./getAllRecipientsAddresses.js";
|
9
|
-
|
10
|
-
const chain = ANVIL_CHAIN;
|
11
|
-
const client = TEST_CLIENT;
|
12
|
-
|
13
|
-
describe.runIf(process.env.TW_SECRET_KEY)("getAllRecipientsAddresses", () => {
|
14
|
-
it("should work", async () => {
|
15
|
-
const payees = [
|
16
|
-
"0x12345674b599ce99958242b3D3741e7b01841DF3",
|
17
|
-
"0xA6f11e47dE28B3dB934e945daeb6F538E9019694",
|
18
|
-
];
|
19
|
-
const address = await deploySplitContract({
|
20
|
-
account: TEST_ACCOUNT_C,
|
21
|
-
client: TEST_CLIENT,
|
22
|
-
chain: ANVIL_CHAIN,
|
23
|
-
params: {
|
24
|
-
name: "split-contract",
|
25
|
-
contractURI: TEST_CONTRACT_URI, // just to speed up the test
|
26
|
-
payees,
|
27
|
-
shares: [
|
28
|
-
5100n, // 51%
|
29
|
-
4900n, // 49%
|
30
|
-
],
|
31
|
-
},
|
32
|
-
});
|
33
|
-
const contract = getContract({
|
34
|
-
address,
|
35
|
-
chain,
|
36
|
-
client,
|
37
|
-
});
|
38
|
-
const result = await getAllRecipientsAddresses({ contract });
|
39
|
-
expect(result).toStrictEqual(payees);
|
40
|
-
});
|
41
|
-
});
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
2
|
-
import { ANVIL_CHAIN } from "~test/chains.js";
|
3
|
-
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
4
|
-
import { TEST_CLIENT } from "~test/test-clients.js";
|
5
|
-
import { TEST_ACCOUNT_C } from "~test/test-wallets.js";
|
6
|
-
import { getContract } from "../../../contract/contract.js";
|
7
|
-
import { deploySplitContract } from "../../../extensions/prebuilts/deploy-split.js";
|
8
|
-
import { getAllRecipientsPercentages } from "./getAllRecipientsPercentages.js";
|
9
|
-
|
10
|
-
const chain = ANVIL_CHAIN;
|
11
|
-
const client = TEST_CLIENT;
|
12
|
-
|
13
|
-
describe.runIf(process.env.TW_SECRET_KEY)("getAllRecipientsPercentages", () => {
|
14
|
-
it("should work", async () => {
|
15
|
-
const payees = [
|
16
|
-
"0x12345674b599ce99958242b3D3741e7b01841DF3",
|
17
|
-
"0xA6f11e47dE28B3dB934e945daeb6F538E9019694",
|
18
|
-
];
|
19
|
-
const address = await deploySplitContract({
|
20
|
-
account: TEST_ACCOUNT_C,
|
21
|
-
client: TEST_CLIENT,
|
22
|
-
chain: ANVIL_CHAIN,
|
23
|
-
params: {
|
24
|
-
name: "split-contract",
|
25
|
-
contractURI: TEST_CONTRACT_URI, // just to speed up the test
|
26
|
-
payees,
|
27
|
-
shares: [
|
28
|
-
5100n, // 51%
|
29
|
-
4900n, // 49%
|
30
|
-
],
|
31
|
-
},
|
32
|
-
});
|
33
|
-
const contract = getContract({
|
34
|
-
address,
|
35
|
-
chain,
|
36
|
-
client,
|
37
|
-
});
|
38
|
-
const result = await getAllRecipientsPercentages({ contract });
|
39
|
-
expect(result).toStrictEqual([
|
40
|
-
{
|
41
|
-
address: "0x12345674b599ce99958242b3D3741e7b01841DF3",
|
42
|
-
splitPercentage: 51,
|
43
|
-
},
|
44
|
-
{
|
45
|
-
address: "0xA6f11e47dE28B3dB934e945daeb6F538E9019694",
|
46
|
-
splitPercentage: 49,
|
47
|
-
},
|
48
|
-
]);
|
49
|
-
});
|
50
|
-
});
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
2
|
-
import { ANVIL_CHAIN } from "~test/chains.js";
|
3
|
-
import { TEST_CONTRACT_URI } from "~test/ipfs-uris.js";
|
4
|
-
import { TEST_CLIENT } from "~test/test-clients.js";
|
5
|
-
import { TEST_ACCOUNT_C } from "~test/test-wallets.js";
|
6
|
-
import { getContract } from "../../../contract/contract.js";
|
7
|
-
import { deploySplitContract } from "../../../extensions/prebuilts/deploy-split.js";
|
8
|
-
import { getRecipientSplitPercentage } from "./getRecipientSplitPercentage.js";
|
9
|
-
|
10
|
-
const chain = ANVIL_CHAIN;
|
11
|
-
const client = TEST_CLIENT;
|
12
|
-
const account = TEST_ACCOUNT_C;
|
13
|
-
|
14
|
-
describe.runIf(process.env.TW_SECRET_KEY)("getRecipientSplitPercentage", () => {
|
15
|
-
it("should work", async () => {
|
16
|
-
const payees = [
|
17
|
-
"0x12345674b599ce99958242b3D3741e7b01841DF3",
|
18
|
-
"0xA6f11e47dE28B3dB934e945daeb6F538E9019694",
|
19
|
-
];
|
20
|
-
const address = await deploySplitContract({
|
21
|
-
account,
|
22
|
-
client: TEST_CLIENT,
|
23
|
-
chain: ANVIL_CHAIN,
|
24
|
-
params: {
|
25
|
-
name: "split-contract",
|
26
|
-
contractURI: TEST_CONTRACT_URI, // just to speed up the test
|
27
|
-
payees,
|
28
|
-
shares: [
|
29
|
-
5100n, // 51%
|
30
|
-
4900n, // 49%
|
31
|
-
],
|
32
|
-
},
|
33
|
-
});
|
34
|
-
const contract = getContract({
|
35
|
-
address,
|
36
|
-
chain,
|
37
|
-
client,
|
38
|
-
});
|
39
|
-
const result = await getRecipientSplitPercentage({
|
40
|
-
contract,
|
41
|
-
recipientAddress: "0x12345674b599ce99958242b3D3741e7b01841DF3",
|
42
|
-
});
|
43
|
-
|
44
|
-
expect(result).toStrictEqual({
|
45
|
-
address: "0x12345674b599ce99958242b3D3741e7b01841DF3",
|
46
|
-
splitPercentage: 51,
|
47
|
-
});
|
48
|
-
});
|
49
|
-
});
|