@reyaxyz/common 0.258.0 → 0.258.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/README.md +1 -1
- package/dist/transactions/contractAddresses.js +1 -1
- package/dist/transactions/contractAddresses.js.map +1 -1
- package/dist/types/utils/sbt-helpers.d.ts +4 -4
- package/dist/types/utils/sbt-helpers.d.ts.map +1 -1
- package/dist/utils/sbt-helpers.js +12 -33
- package/dist/utils/sbt-helpers.js.map +1 -1
- package/package.json +3 -5
- package/src/transactions/contractAddresses.ts +1 -1
- package/src/utils/sbt-helpers.ts +13 -43
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -36,7 +36,7 @@ var addresses = (_a = {},
|
|
|
36
36
|
_c[ContractType.ORACLE_ADAPTERS_PROXY] = '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',
|
|
37
37
|
_c[ContractType.MULTICALL] = '0xed28d27dfca47ad2513c9f2e2d3c098c2ea5a47f',
|
|
38
38
|
_c[ContractType.CAMELOT_YAK_ROUTER] = '0x2b59eb03865d18d8b62a5956bbbfae352fc1c148',
|
|
39
|
-
_c[ContractType.REYA_SBTS] = '',
|
|
39
|
+
_c[ContractType.REYA_SBTS] = '0x14d7c1efc024e118df70b241afbd2447d37f1ed6',
|
|
40
40
|
_c),
|
|
41
41
|
_a);
|
|
42
42
|
var getAddress = function (chainId, contractName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractAddresses.js","sourceRoot":"/","sources":["transactions/contractAddresses.ts"],"names":[],"mappings":";;;;AAAA,kCAAgD;AAEhD,IAAY,YAUX;AAVD,WAAY,YAAY;IACtB,yCAAyB,CAAA;IACzB,yDAAyC,CAAA;IACzC,mDAAmC,CAA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AE1B,IAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,6CAAsC,UAAU,CAAE,CAAC,CAAC;IACtE,CAAC;IAED,IAAM,gBAAgB,GAAG,SAAS,CAAC,OAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,kCAA2B,YAAY,cAAW,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC;AAhBW,QAAA,UAAU,cAgBrB","sourcesContent":["import { Address, ReyaChainId } from '../types';\n\nexport enum ContractType {\n CORE_PROXY = 'core_proxy',\n PASSIVE_POOL_PROXY = 'passive_pool_proxy',\n PERIPHERY_PROXY = 'periphery_proxy',\n CONDITIONAL_ORDERS_PROXY = 'conditional_orders_proxy',\n PASSIVE_PERP_PROXY = 'passive_perp_proxy',\n ORACLE_ADAPTERS_PROXY = 'oracle_adapters_proxy',\n MULTICALL = 'multicall',\n CAMELOT_YAK_ROUTER = 'camelot_yak_router',\n REYA_SBTS = 'reya_sbts',\n}\n\nconst addresses: Record<ReyaChainId, Record<ContractType, Address>> = {\n [ReyaChainId.reyaCronos]: {\n [ContractType.CORE_PROXY]: '0xc6fb022962e1426f4e0ec9d2f8861c57926e9f72',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0x9a3a664987b88790a6fdc1632e3b607813fd94ff',\n [ContractType.PERIPHERY_PROXY]:\n '0x94ccae812f1647696754412082dd6684c2366a7f',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x9ec177fed042ef2307928be2f5cdbf663b20244b',\n [ContractType.ORACLE_ADAPTERS_PROXY]:\n '0xc501a2356703cd351703d68963c6f4136120f7cf',\n [ContractType.MULTICALL]: '0x5abde4f0af8eaf3c9967f7fa126e59a103357b5c',\n [ContractType.CAMELOT_YAK_ROUTER]:\n '0x2b59eb03865d18d8b62a5956bbbfae352fc1c148',\n [ContractType.REYA_SBTS]: '0xc0092ea9179ace93b0cd8910958e335575562722',\n },\n [ReyaChainId.reyaNetwork]: {\n [ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',\n [ContractType.PASSIVE_POOL_PROXY]:\n '0xb4b77d6180cc14472a9a7bdff01cc2459368d413',\n [ContractType.PERIPHERY_PROXY]:\n '0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',\n [ContractType.CONDITIONAL_ORDERS_PROXY]:\n '0xfc8c96be87da63cecddbf54abfa7b13ee8044739',\n [ContractType.PASSIVE_PERP_PROXY]:\n '0x27e5cb712334e101b3c232eb0be198baaa595f5f',\n [ContractType.ORACLE_ADAPTERS_PROXY]:\n '0x32edabc058c1207fe0ec5f8557643c28e4ff379e',\n [ContractType.MULTICALL]: '0xed28d27dfca47ad2513c9f2e2d3c098c2ea5a47f',\n [ContractType.CAMELOT_YAK_ROUTER]:\n '0x2b59eb03865d18d8b62a5956bbbfae352fc1c148',\n [ContractType.REYA_SBTS]: '0x14d7c1efc024e118df70b241afbd2447d37f1ed6',\n },\n};\nexport const getAddress = (\n chainId: number,\n contractName: ContractType,\n): Address => {\n const keyChainId = chainId.toString();\n\n if (!Object.keys(addresses).includes(keyChainId)) {\n throw new Error(`Unspecified addresses for chain id ${keyChainId}`);\n }\n\n const networkAddresses = addresses[chainId as ReyaChainId];\n if (!Object.keys(networkAddresses).includes(contractName)) {\n throw new Error(`Unspecified address for ${contractName} contract`);\n }\n\n return networkAddresses[contractName];\n};\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { BigNumberish } from 'ethers';
|
|
3
|
-
|
|
3
|
+
import { ReyaChainId } from '../types';
|
|
4
|
+
export declare const SBT_ROOT: Record<ReyaChainId, string>;
|
|
5
|
+
export declare const getSbtRoot: (reyaChainId: ReyaChainId) => string;
|
|
4
6
|
export declare const SBT_MINT_DEADLINE = 1743508800;
|
|
5
7
|
export type SbtLeafInfo = {
|
|
6
8
|
account: string;
|
|
7
9
|
tokenRootCounter: number;
|
|
8
10
|
};
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const getMerkleTreeRootInHex: (leaves: Array<SbtLeafInfo>) => string;
|
|
11
|
-
export declare const getMerkleTreeProof: (owner: string, tokenRootCounter: number, leaves: Array<SbtLeafInfo>) => string[];
|
|
11
|
+
export declare const getLeaf: (address: string, tokenRootCounter: number) => Buffer;
|
|
12
12
|
export declare const getSbtTokenId: (account: string, merkleRoot: string, tokenRootCounter: number) => BigNumberish;
|
|
13
13
|
//# sourceMappingURL=sbt-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sbt-helpers.d.ts","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"sbt-helpers.d.ts","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAKhD,CAAC;AAEF,eAAO,MAAM,UAAU,gBAAiB,WAAW,WAElD,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAE5C,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,OAAO,YAAa,MAAM,oBAAoB,MAAM,KAAG,MAQnE,CAAC;AAEF,eAAO,MAAM,aAAa,YACf,MAAM,cACH,MAAM,oBACA,MAAM,KACvB,YASF,CAAC"}
|
|
@@ -1,44 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
2
|
+
var _a;
|
|
5
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSbtTokenId = exports.
|
|
7
|
-
var merkletreejs_1 = require("merkletreejs");
|
|
8
|
-
var keccak256_1 = __importDefault(require("keccak256"));
|
|
4
|
+
exports.getSbtTokenId = exports.getLeaf = exports.SBT_MINT_DEADLINE = exports.getSbtRoot = exports.SBT_ROOT = void 0;
|
|
9
5
|
var ethers_1 = require("ethers");
|
|
10
|
-
|
|
6
|
+
var types_1 = require("../types");
|
|
7
|
+
exports.SBT_ROOT = (_a = {},
|
|
8
|
+
_a[types_1.ReyaChainId.reyaNetwork] = '0x7d8254a884c4e1e8040d592fdbe3ce8986fb6c5c4f7dee3ce7b7f823fa127c52',
|
|
9
|
+
_a[types_1.ReyaChainId.reyaCronos] = '0x01f4d29a3aca5cb40663851d2d40d605636dd6448f251d77765dd0e40c422136',
|
|
10
|
+
_a);
|
|
11
|
+
var getSbtRoot = function (reyaChainId) {
|
|
12
|
+
return exports.SBT_ROOT[reyaChainId];
|
|
13
|
+
};
|
|
14
|
+
exports.getSbtRoot = getSbtRoot;
|
|
11
15
|
exports.SBT_MINT_DEADLINE = 1743508800; // Tue Apr 01 2025 12:00:00 GMT+0000
|
|
12
16
|
var getLeaf = function (address, tokenRootCounter) {
|
|
13
17
|
var messageHash = ethers_1.ethers.keccak256(ethers_1.ethers.solidityPacked(['address', 'uint256'], [address, tokenRootCounter.toString()]));
|
|
14
18
|
return Buffer.from(messageHash.slice(2), 'hex');
|
|
15
19
|
};
|
|
16
|
-
|
|
17
|
-
var leafNodes = leaves.map(function (entry) {
|
|
18
|
-
return getLeaf(entry.account, entry.tokenRootCounter);
|
|
19
|
-
});
|
|
20
|
-
var merkleTree = new merkletreejs_1.MerkleTree(leafNodes, keccak256_1.default, { sortPairs: true });
|
|
21
|
-
return merkleTree;
|
|
22
|
-
};
|
|
23
|
-
var getMerkleTreeRoot = function (leaves) {
|
|
24
|
-
var merkleTree = getMerkleTree(leaves);
|
|
25
|
-
return merkleTree.getRoot();
|
|
26
|
-
};
|
|
27
|
-
exports.getMerkleTreeRoot = getMerkleTreeRoot;
|
|
28
|
-
var getMerkleTreeRootInHex = function (leaves) {
|
|
29
|
-
var merkleTree = getMerkleTree(leaves);
|
|
30
|
-
return merkleTree.getHexRoot();
|
|
31
|
-
};
|
|
32
|
-
exports.getMerkleTreeRootInHex = getMerkleTreeRootInHex;
|
|
33
|
-
var getMerkleTreeProof = function (owner, tokenRootCounter, leaves) {
|
|
34
|
-
var merkleTree = getMerkleTree(leaves);
|
|
35
|
-
var proof = merkleTree.getHexProof(getLeaf(owner, tokenRootCounter));
|
|
36
|
-
if (proof.length === 0) {
|
|
37
|
-
throw new Error("Cannot prove something that is not in tree: { address: ".concat(owner, ", tokenRootCounter: ").concat(tokenRootCounter, "}"));
|
|
38
|
-
}
|
|
39
|
-
return proof;
|
|
40
|
-
};
|
|
41
|
-
exports.getMerkleTreeProof = getMerkleTreeProof;
|
|
20
|
+
exports.getLeaf = getLeaf;
|
|
42
21
|
var getSbtTokenId = function (account, merkleRoot, tokenRootCounter) {
|
|
43
22
|
return ethers_1.ethers.toBigInt(ethers_1.ethers.keccak256(ethers_1.ethers.solidityPacked(['address', 'bytes32', 'uint256'], [account, merkleRoot, tokenRootCounter.toString()])));
|
|
44
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sbt-helpers.js","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sbt-helpers.js","sourceRoot":"/","sources":["utils/sbt-helpers.ts"],"names":[],"mappings":";;;;AAAA,iCAA8C;AAC9C,kCAAuC;AAE1B,QAAA,QAAQ;IACnB,GAAC,mBAAW,CAAC,WAAW,IACtB,oEAAoE;IACtE,GAAC,mBAAW,CAAC,UAAU,IACrB,oEAAoE;QACtE;AAEK,IAAM,UAAU,GAAG,UAAC,WAAwB;IACjD,OAAO,gBAAQ,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEW,QAAA,iBAAiB,GAAG,UAAU,CAAC,CAAC,oCAAoC;AAO1E,IAAM,OAAO,GAAG,UAAC,OAAe,EAAE,gBAAwB;IAC/D,IAAM,WAAW,GAAG,eAAM,CAAC,SAAS,CAClC,eAAM,CAAC,cAAc,CACnB,CAAC,SAAS,EAAE,SAAS,CAAC,EACtB,CAAC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CACvC,CACF,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AARW,QAAA,OAAO,WAQlB;AAEK,IAAM,aAAa,GAAG,UAC3B,OAAe,EACf,UAAkB,EAClB,gBAAwB;IAExB,OAAO,eAAM,CAAC,QAAQ,CACpB,eAAM,CAAC,SAAS,CACd,eAAM,CAAC,cAAc,CACnB,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EACjC,CAAC,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CACnD,CACF,CACF,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,aAAa,iBAaxB","sourcesContent":["import { ethers, BigNumberish } from 'ethers';\nimport { ReyaChainId } from '../types';\n\nexport const SBT_ROOT: Record<ReyaChainId, string> = {\n [ReyaChainId.reyaNetwork]:\n '0x7d8254a884c4e1e8040d592fdbe3ce8986fb6c5c4f7dee3ce7b7f823fa127c52',\n [ReyaChainId.reyaCronos]:\n '0x01f4d29a3aca5cb40663851d2d40d605636dd6448f251d77765dd0e40c422136',\n};\n\nexport const getSbtRoot = (reyaChainId: ReyaChainId) => {\n return SBT_ROOT[reyaChainId];\n};\n\nexport const SBT_MINT_DEADLINE = 1743508800; // Tue Apr 01 2025 12:00:00 GMT+0000\n\nexport type SbtLeafInfo = {\n account: string;\n tokenRootCounter: number;\n};\n\nexport const getLeaf = (address: string, tokenRootCounter: number): Buffer => {\n const messageHash = ethers.keccak256(\n ethers.solidityPacked(\n ['address', 'uint256'],\n [address, tokenRootCounter.toString()],\n ),\n );\n return Buffer.from(messageHash.slice(2), 'hex');\n};\n\nexport const getSbtTokenId = (\n account: string,\n merkleRoot: string,\n tokenRootCounter: number,\n): BigNumberish => {\n return ethers.toBigInt(\n ethers.keccak256(\n ethers.solidityPacked(\n ['address', 'bytes32', 'uint256'],\n [account, merkleRoot, tokenRootCounter.toString()],\n ),\n ),\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/common",
|
|
3
|
-
"version": "0.258.
|
|
3
|
+
"version": "0.258.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -26,9 +26,7 @@
|
|
|
26
26
|
"bignumber.js": "^9.1.2",
|
|
27
27
|
"ethers": "6.9.0",
|
|
28
28
|
"ethers-decode-error": "^2.1.3",
|
|
29
|
-
"
|
|
30
|
-
"lodash.clonedeep": "4.5.0",
|
|
31
|
-
"merkletreejs": "^0.3.0"
|
|
29
|
+
"lodash.clonedeep": "4.5.0"
|
|
32
30
|
},
|
|
33
31
|
"scripts": {
|
|
34
32
|
"prebuild": "rm -rf node_modules && rm -rf dist",
|
|
@@ -46,5 +44,5 @@
|
|
|
46
44
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
47
45
|
},
|
|
48
46
|
"packageManager": "pnpm@8.3.1",
|
|
49
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "89681cc59978865f94679b02ce077f552af105f2"
|
|
50
48
|
}
|
|
@@ -45,7 +45,7 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
|
|
|
45
45
|
[ContractType.MULTICALL]: '0xed28d27dfca47ad2513c9f2e2d3c098c2ea5a47f',
|
|
46
46
|
[ContractType.CAMELOT_YAK_ROUTER]:
|
|
47
47
|
'0x2b59eb03865d18d8b62a5956bbbfae352fc1c148',
|
|
48
|
-
[ContractType.REYA_SBTS]: '',
|
|
48
|
+
[ContractType.REYA_SBTS]: '0x14d7c1efc024e118df70b241afbd2447d37f1ed6',
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
export const getAddress = (
|
package/src/utils/sbt-helpers.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { MerkleTree } from 'merkletreejs';
|
|
2
|
-
import keccak256 from 'keccak256';
|
|
3
1
|
import { ethers, BigNumberish } from 'ethers';
|
|
2
|
+
import { ReyaChainId } from '../types';
|
|
3
|
+
|
|
4
|
+
export const SBT_ROOT: Record<ReyaChainId, string> = {
|
|
5
|
+
[ReyaChainId.reyaNetwork]:
|
|
6
|
+
'0x7d8254a884c4e1e8040d592fdbe3ce8986fb6c5c4f7dee3ce7b7f823fa127c52',
|
|
7
|
+
[ReyaChainId.reyaCronos]:
|
|
8
|
+
'0x01f4d29a3aca5cb40663851d2d40d605636dd6448f251d77765dd0e40c422136',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const getSbtRoot = (reyaChainId: ReyaChainId) => {
|
|
12
|
+
return SBT_ROOT[reyaChainId];
|
|
13
|
+
};
|
|
4
14
|
|
|
5
|
-
export const SBT_ROOT =
|
|
6
|
-
'0x7d8254a884c4e1e8040d592fdbe3ce8986fb6c5c4f7dee3ce7b7f823fa127c52';
|
|
7
15
|
export const SBT_MINT_DEADLINE = 1743508800; // Tue Apr 01 2025 12:00:00 GMT+0000
|
|
8
16
|
|
|
9
17
|
export type SbtLeafInfo = {
|
|
@@ -11,7 +19,7 @@ export type SbtLeafInfo = {
|
|
|
11
19
|
tokenRootCounter: number;
|
|
12
20
|
};
|
|
13
21
|
|
|
14
|
-
const getLeaf = (address: string, tokenRootCounter: number): Buffer => {
|
|
22
|
+
export const getLeaf = (address: string, tokenRootCounter: number): Buffer => {
|
|
15
23
|
const messageHash = ethers.keccak256(
|
|
16
24
|
ethers.solidityPacked(
|
|
17
25
|
['address', 'uint256'],
|
|
@@ -21,44 +29,6 @@ const getLeaf = (address: string, tokenRootCounter: number): Buffer => {
|
|
|
21
29
|
return Buffer.from(messageHash.slice(2), 'hex');
|
|
22
30
|
};
|
|
23
31
|
|
|
24
|
-
const getMerkleTree = (leaves: Array<SbtLeafInfo>): MerkleTree => {
|
|
25
|
-
const leafNodes = leaves.map((entry) => {
|
|
26
|
-
return getLeaf(entry.account, entry.tokenRootCounter);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const merkleTree = new MerkleTree(leafNodes, keccak256, { sortPairs: true });
|
|
30
|
-
|
|
31
|
-
return merkleTree;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const getMerkleTreeRoot = (leaves: Array<SbtLeafInfo>): Buffer => {
|
|
35
|
-
const merkleTree = getMerkleTree(leaves);
|
|
36
|
-
return merkleTree.getRoot();
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const getMerkleTreeRootInHex = (leaves: Array<SbtLeafInfo>): string => {
|
|
40
|
-
const merkleTree = getMerkleTree(leaves);
|
|
41
|
-
return merkleTree.getHexRoot();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const getMerkleTreeProof = (
|
|
45
|
-
owner: string,
|
|
46
|
-
tokenRootCounter: number,
|
|
47
|
-
leaves: Array<SbtLeafInfo>,
|
|
48
|
-
): string[] => {
|
|
49
|
-
const merkleTree = getMerkleTree(leaves);
|
|
50
|
-
|
|
51
|
-
const proof = merkleTree.getHexProof(getLeaf(owner, tokenRootCounter));
|
|
52
|
-
|
|
53
|
-
if (proof.length === 0) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
`Cannot prove something that is not in tree: { address: ${owner}, tokenRootCounter: ${tokenRootCounter}}`,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return proof;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
32
|
export const getSbtTokenId = (
|
|
63
33
|
account: string,
|
|
64
34
|
merkleRoot: string,
|