@helium/lazy-transactions-sdk 0.2.21 → 0.2.22-next.33

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
7
7
  "license": "Apache-2.0",
8
- "version": "0.2.21",
8
+ "version": "0.2.22-next.33+2a1e1998",
9
9
  "description": "Interface to the lazy-transactions smart contract",
10
10
  "repository": {
11
11
  "type": "git",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@coral-xyz/anchor": "^0.26.0",
35
- "@helium/idls": "^0.2.21",
36
- "@helium/spl-utils": "^0.2.21",
35
+ "@helium/idls": "^0.2.22-next.33+2a1e1998",
36
+ "@helium/spl-utils": "^0.2.22-next.33+2a1e1998",
37
37
  "bn.js": "^5.2.0",
38
38
  "bs58": "^4.0.1",
39
39
  "js-sha3": "^0.8.0",
@@ -42,9 +42,9 @@
42
42
  "devDependencies": {
43
43
  "git-format-staged": "^2.1.3",
44
44
  "ts-loader": "^9.2.3",
45
- "ts-node": "^10.8.1",
46
- "typescript": "^4.3.4",
45
+ "ts-node": "^10.9.1",
46
+ "typescript": "^4.8.4",
47
47
  "yarn": "^1.22.18"
48
48
  },
49
- "gitHead": "be9f93a17b2a7193d9aa0326b815d336ae684343"
49
+ "gitHead": "2a1e19980d74c21b5f51834540421b3c8a0a045e"
50
50
  }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROGRAM_ID = void 0;
4
- const web3_js_1 = require("@solana/web3.js");
5
- exports.PROGRAM_ID = new web3_js_1.PublicKey("1atrmQs3eq1N2FEYWu6tyTXbCjP4uQwExpjtnhXtS8h");
6
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE/B,QAAA,UAAU,GAAG,IAAI,mBAAS,CAAC,6CAA6C,CAAC,CAAC"}
package/lib/cjs/index.js DELETED
@@ -1,271 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
- };
28
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
- return new (P || (P = Promise))(function (resolve, reject) {
31
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
- step((generator = generator.apply(thisArg, _arguments || [])).next());
35
- });
36
- };
37
- var __importDefault = (this && this.__importDefault) || function (mod) {
38
- return (mod && mod.__esModule) ? mod : { "default": mod };
39
- };
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.compileNoMerkle = exports.compile = exports.fillCanopy = exports.getCanopy = exports.getCanopySize = exports.toLeaf = exports.ixFromBin = exports.ixToBin = exports.numBytesCompiledTx = exports.compiledIxLayout = exports.getCompiledInstructions = exports.getAccounts = exports.init = exports.MerkleTree = void 0;
42
- const anchor_1 = require("@coral-xyz/anchor");
43
- const idl_1 = require("@coral-xyz/anchor/dist/cjs/coder/borsh/idl");
44
- const web3_js_1 = require("@solana/web3.js");
45
- const js_sha3_1 = require("js-sha3");
46
- const constants_1 = require("./constants");
47
- const merkleTree_1 = require("./merkleTree");
48
- Object.defineProperty(exports, "MerkleTree", { enumerable: true, get: function () { return merkleTree_1.MerkleTree; } });
49
- const spl_utils_1 = require("@helium/spl-utils");
50
- const cli_progress_1 = __importDefault(require("cli-progress"));
51
- const Collections = __importStar(require("typescript-collections"));
52
- __exportStar(require("./constants"), exports);
53
- __exportStar(require("./pdas"), exports);
54
- function init(provider, programId = constants_1.PROGRAM_ID, idl) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- if (!idl) {
57
- idl = yield anchor_1.Program.fetchIdl(programId, provider);
58
- }
59
- const lazyTransactions = new anchor_1.Program(idl, programId, provider);
60
- return lazyTransactions;
61
- });
62
- }
63
- exports.init = init;
64
- function getAccounts(lazySigner, instructions, mapToNonSigners) {
65
- const accounts = {};
66
- const nonSigners = new Set(mapToNonSigners.map((s) => s.toBase58()));
67
- instructions.forEach((ix) => {
68
- var _a;
69
- accounts[_a = ix.programId.toBase58()] || (accounts[_a] = {
70
- pubkey: ix.programId,
71
- isWritable: false,
72
- isSigner: false,
73
- });
74
- ix.keys.forEach((key) => {
75
- const pubkey = key.pubkey.toBase58();
76
- const isLazyTransactions = key.pubkey.equals(lazySigner);
77
- accounts[pubkey] = accounts[pubkey] || key;
78
- // Always not a signer if it's lazy transactions (will cpi sign)
79
- accounts[pubkey].isSigner = isLazyTransactions
80
- ? false
81
- : nonSigners.has(pubkey)
82
- ? false
83
- : accounts[pubkey].isSigner || key.isSigner;
84
- // Always writable if it's lazy transactions.
85
- accounts[pubkey].isWritable =
86
- isLazyTransactions || accounts[pubkey].isWritable || key.isWritable;
87
- });
88
- });
89
- return Object.values(accounts);
90
- }
91
- exports.getAccounts = getAccounts;
92
- function getCompiledInstructions(accounts, instructions) {
93
- const accountIndicesByKey = accounts.reduce((acc, account, index) => {
94
- acc[account.pubkey.toBase58()] = index;
95
- return acc;
96
- }, {});
97
- return instructions.map((instruction) => {
98
- return {
99
- programIdIndex: accountIndicesByKey[instruction.programId.toBase58()],
100
- accounts: Buffer.from(instruction.keys.map((key) => accountIndicesByKey[key.pubkey.toBase58()])),
101
- data: instruction.data,
102
- };
103
- });
104
- }
105
- exports.getCompiledInstructions = getCompiledInstructions;
106
- const CompiledInstructionDef = {
107
- name: "CompiledInstruction",
108
- type: {
109
- kind: "struct",
110
- fields: [
111
- {
112
- name: "programIdIndex",
113
- type: "u8",
114
- },
115
- {
116
- name: "accounts",
117
- type: "bytes",
118
- },
119
- {
120
- name: "data",
121
- type: "bytes",
122
- },
123
- ],
124
- },
125
- };
126
- exports.compiledIxLayout = idl_1.IdlCoder.typeDefLayout(CompiledInstructionDef);
127
- function numBytesCompiledTx(compiledIx) {
128
- return 1 + 4 * 2 + compiledIx.accounts.length + compiledIx.data.length;
129
- }
130
- exports.numBytesCompiledTx = numBytesCompiledTx;
131
- function ixToBin(ct) {
132
- const ixBuffer = Buffer.alloc(numBytesCompiledTx(ct));
133
- exports.compiledIxLayout.encode(ct, ixBuffer);
134
- return ixBuffer;
135
- }
136
- exports.ixToBin = ixToBin;
137
- function ixFromBin(ct) {
138
- return exports.compiledIxLayout.decode(ct);
139
- }
140
- exports.ixFromBin = ixFromBin;
141
- function toLeaf(compiledTransaction) {
142
- const ixBuffer = Buffer.concat(compiledTransaction.instructions.map(ixToBin));
143
- const accountBuffer = Buffer.concat(compiledTransaction.accounts.map((account) => account.pubkey.toBuffer()));
144
- const indexBuffer = Buffer.alloc(4);
145
- indexBuffer.writeUInt32LE(compiledTransaction.index);
146
- const toCreate = compiledTransaction.signerSeeds.reduce((acc, curr) => Buffer.concat([acc, Buffer.concat(curr)]), Buffer.from([]));
147
- const bytes = Buffer.concat([accountBuffer, ixBuffer, toCreate, indexBuffer]);
148
- return Buffer.from(js_sha3_1.keccak_256.digest(bytes));
149
- }
150
- exports.toLeaf = toLeaf;
151
- function getCanopySize(canopyDepth) {
152
- return 1 + Math.max(((1 << (canopyDepth + 1)) - 2) * 32, 0);
153
- }
154
- exports.getCanopySize = getCanopySize;
155
- function getCanopy({ merkleTree, cacheDepth, }) {
156
- let curr = merkleTree.leaves[0];
157
- while (curr.parent) {
158
- curr = curr.parent;
159
- }
160
- const root = curr;
161
- const canopy = [];
162
- const q = new Collections.Queue();
163
- q.enqueue(root);
164
- let maxLevel = root.level;
165
- while (!q.isEmpty()) {
166
- const curr = q.dequeue();
167
- if (maxLevel - curr.level > cacheDepth) {
168
- break;
169
- }
170
- if (curr.left) {
171
- q.enqueue(curr.left);
172
- }
173
- else if (curr.level >= 1) {
174
- // add dummy leaves
175
- q.enqueue({
176
- node: Buffer.alloc(32),
177
- left: undefined,
178
- right: undefined,
179
- parent: curr,
180
- level: curr.level - 1,
181
- id: 0,
182
- });
183
- }
184
- if (curr.right) {
185
- q.enqueue(curr.right);
186
- }
187
- else if (curr.level >= 1) {
188
- // add dummy leaves
189
- q.enqueue({
190
- node: Buffer.alloc(32),
191
- left: undefined,
192
- right: undefined,
193
- parent: curr,
194
- level: curr.level - 1,
195
- id: 0,
196
- });
197
- }
198
- canopy.push(curr);
199
- }
200
- canopy.shift(); // remove root
201
- return canopy;
202
- }
203
- exports.getCanopy = getCanopy;
204
- ;
205
- function fillCanopy({ program, lazyTransactions, merkleTree, canopy, cacheDepth, showProgress = false, }) {
206
- return __awaiter(this, void 0, void 0, function* () {
207
- if (!canopy) {
208
- canopy = getCanopy({
209
- merkleTree: merkleTree,
210
- cacheDepth,
211
- });
212
- }
213
- // Write 30 leaves at a time
214
- const lazyTransactionsAcc = yield program.account.lazyTransactionsV0.fetch(lazyTransactions);
215
- const chunkSize = 30;
216
- const canopyChunks = (0, spl_utils_1.chunks)(canopy, chunkSize);
217
- let progress;
218
- if (showProgress) {
219
- console.log("Setting canopy");
220
- progress = new cli_progress_1.default.SingleBar({}, cli_progress_1.default.Presets.shades_classic);
221
- progress.start(canopy.length, 0);
222
- }
223
- const txs = yield Promise.all(canopyChunks.map((leaves, index) => __awaiter(this, void 0, void 0, function* () {
224
- const bytes = Buffer.concat(leaves.map((leaf) => leaf.node));
225
- const tx = yield program.methods
226
- .setCanopyV0({
227
- offset: 32 * chunkSize * index,
228
- bytes,
229
- })
230
- .accountsStrict({
231
- lazyTransactions,
232
- canopy: lazyTransactionsAcc.canopy,
233
- authority: lazyTransactionsAcc.authority,
234
- })
235
- .transaction();
236
- // @ts-ignore
237
- tx.feePayer = program.provider.wallet.publicKey;
238
- return tx;
239
- })));
240
- // Bulk send txs
241
- yield (0, spl_utils_1.bulkSendTransactions)(program.provider, txs, ({ totalProgress }) => progress && progress.update(totalProgress * chunkSize));
242
- });
243
- }
244
- exports.fillCanopy = fillCanopy;
245
- function compile(lazySigner, transactions, programId = constants_1.PROGRAM_ID) {
246
- const compiledTransactions = compileNoMerkle(lazySigner, transactions, programId);
247
- const merkleTree = new merkleTree_1.MerkleTree(compiledTransactions.map(toLeaf));
248
- return {
249
- compiledTransactions,
250
- merkleTree,
251
- };
252
- }
253
- exports.compile = compile;
254
- function compileNoMerkle(lazySigner, transactions, programId = constants_1.PROGRAM_ID) {
255
- const compiledTransactions = transactions.map((tx, index) => {
256
- const mapToNonSigners = tx.signerSeeds.map((seeds) => {
257
- return web3_js_1.PublicKey.createProgramAddressSync(seeds, programId);
258
- });
259
- const accounts = getAccounts(lazySigner, tx.instructions, mapToNonSigners);
260
- const compiledInstructions = getCompiledInstructions(accounts, tx.instructions);
261
- return {
262
- instructions: compiledInstructions,
263
- signerSeeds: tx.signerSeeds.map((ss) => ss.slice(2)),
264
- accounts,
265
- index,
266
- };
267
- });
268
- return compiledTransactions;
269
- }
270
- exports.compileNoMerkle = compileNoMerkle;
271
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA2E;AAC3E,oEAAsE;AAEtE,6CAIyB;AACzB,qCAAqC;AACrC,2CAAyC;AACzC,6CAAoD;AAS3C,2FATA,uBAAU,OASA;AARnB,iDAAiE;AAGjE,gEAAuC;AACvC,oEAAsD;AAEtD,8CAA4B;AAC5B,yCAAuB;AAKvB,SAAsB,IAAI,CACxB,QAAwB,EACxB,YAAuB,sBAAU,EACjC,GAAgB;;QAEhB,IAAI,CAAC,GAAG,EAAE;YACR,GAAG,GAAG,MAAM,gBAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;SACnD;QACD,MAAM,gBAAgB,GAAG,IAAI,gBAAO,CAClC,GAAuB,EACvB,SAAS,EACT,QAAQ,CACoB,CAAC;QAC/B,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CAAA;AAdD,oBAcC;AAED,SAAgB,WAAW,CACzB,UAAqB,EACrB,YAAsC,EACtC,eAA4B;IAE5B,MAAM,QAAQ,GAAgC,EAAE,CAAC;IACjD,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAErE,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;;QAC1B,QAAQ,MAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAhC,QAAQ,OAA8B;YACpC,MAAM,EAAE,EAAE,CAAC,SAAS;YACpB,UAAU,EAA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AC,EAAE,EAAE,KAAK,EAAE,EAAE;QAC1D,MAAM,eAAe,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACnD,OAAO,mBAAS,CAAC,wBAAwB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,WAAW,CAAC,UAAU,EAAE,EAAE,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QAC3E,MAAM,oBAAoB,GAAG,uBAAuB,CAClD,QAAQ,EACR,EAAE,CAAC,YAAY,CAChB,CAAC;QACF,OAAO;YACL,YAAY,EAAE,oBAAoB;YAClC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACpD,QAAQ;YACR,KAAK;SACN,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,oBAAoB,CAAA;AAC7B,CAAC;AAvBD,0CAuBC"}
@@ -1,247 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.emptyNode = exports.hash = exports.MerkleTree = exports.LEAF_BUFFER_LENGTH = void 0;
30
- const js_sha3_1 = __importDefault(require("js-sha3"));
31
- const Collections = __importStar(require("typescript-collections"));
32
- const web3_js_1 = require("@solana/web3.js");
33
- const { keccak_256 } = js_sha3_1.default;
34
- let CACHE_EMPTY_NODE = new Map();
35
- exports.LEAF_BUFFER_LENGTH = 32;
36
- class MerkleTree {
37
- constructor(leaves) {
38
- let [nodes, finalLeaves] = buildLeaves(leaves);
39
- let seqNum = leaves.length;
40
- while (nodes.size() > 1) {
41
- let left = nodes.dequeue();
42
- const level = left.level;
43
- let right;
44
- if (level != nodes.peek().level) {
45
- right = emptyTreeNode(level, seqNum);
46
- seqNum++;
47
- }
48
- else {
49
- right = nodes.dequeue();
50
- }
51
- let parent = {
52
- node: hash(left.node, right.node),
53
- left: left,
54
- right: right,
55
- parent: undefined,
56
- level: level + 1,
57
- id: seqNum,
58
- };
59
- left.parent = parent;
60
- right.parent = parent;
61
- nodes.enqueue(parent);
62
- seqNum++;
63
- }
64
- this.leaves = finalLeaves;
65
- this.root = nodes.peek().node;
66
- this.depth = nodes.peek().level + 1;
67
- }
68
- getRoot() {
69
- return this.root;
70
- }
71
- getProof(leafIndex, minimizeProofHeight = false, treeHeight = -1, verbose = false, verify = true) {
72
- let proof = [];
73
- let node = this.leaves[leafIndex];
74
- let height = 0;
75
- while (typeof node.parent !== "undefined") {
76
- if (minimizeProofHeight && height >= treeHeight) {
77
- break;
78
- }
79
- if (verbose) {
80
- console.log(`${node.level}: ${Uint8Array.from(node.node)}`);
81
- }
82
- let parent = node.parent;
83
- if (parent.left.id === node.id) {
84
- proof.push(parent.right);
85
- if (verify) {
86
- const hashed = hash(node.node, parent.right.node);
87
- if (!hashed.equals(parent.node)) {
88
- console.log(hashed);
89
- console.log(parent.node);
90
- throw new Error("Invariant broken when hashing left node");
91
- }
92
- }
93
- }
94
- else {
95
- proof.push(parent.left);
96
- if (verify) {
97
- const hashed = hash(parent.left.node, node.node);
98
- if (!hashed.equals(parent.node)) {
99
- console.log(hashed);
100
- console.log(parent.node);
101
- throw new Error("Invariant broken when hashing right node");
102
- }
103
- }
104
- }
105
- node = parent;
106
- height++;
107
- }
108
- return {
109
- leafIndex,
110
- leaf: this.leaves[leafIndex].node,
111
- root: this.getRoot(),
112
- proof: proof.map((treeNode) => treeNode.node),
113
- };
114
- }
115
- updateLeaf(leafIndex, newLeaf, verbose = false) {
116
- let leaf = this.leaves[leafIndex];
117
- leaf.node = newLeaf;
118
- let node = leaf;
119
- var i = 0;
120
- while (typeof node.parent !== "undefined") {
121
- if (verbose) {
122
- console.log(`${i}: ${Uint8Array.from(node.node)}`);
123
- }
124
- node = node.parent;
125
- node.node = hash(node.left.node, node.right.node);
126
- i++;
127
- }
128
- if (verbose) {
129
- console.log(`${i}: ${Uint8Array.from(node.node)}`);
130
- }
131
- this.root = node.node;
132
- }
133
- verify(root, merkleTreeProof, verbose = false) {
134
- const { leaf, leafIndex, proof } = merkleTreeProof;
135
- let node = new web3_js_1.PublicKey(leaf).toBuffer();
136
- for (let i = 0; i < proof.length; i++) {
137
- if ((leafIndex >> i) % 2 === 0) {
138
- node = hash(node, new web3_js_1.PublicKey(proof[i]).toBuffer());
139
- }
140
- else {
141
- node = hash(new web3_js_1.PublicKey(proof[i]).toBuffer(), node);
142
- }
143
- if (verbose)
144
- console.log(`node ${i} ${new web3_js_1.PublicKey(node).toString()}`);
145
- }
146
- const rehashed = new web3_js_1.PublicKey(node).toString();
147
- const received = new web3_js_1.PublicKey(root).toString();
148
- if (verbose)
149
- console.log(`hashed ${rehashed} got ${received}`);
150
- if (rehashed !== received) {
151
- throw new Error("Roots don't match!!!");
152
- }
153
- return rehashed === received;
154
- }
155
- }
156
- exports.MerkleTree = MerkleTree;
157
- /**
158
- * Uses on-chain hash fn to hash together buffers
159
- */
160
- function hash(left, right) {
161
- return Buffer.from(keccak_256.digest(Buffer.concat([left, right])));
162
- }
163
- exports.hash = hash;
164
- /*
165
- Breadth-first iteration over a merkle tree
166
- */
167
- // export function bfs<T>(tree: Tree, iterFunc: (node: TreeNode, nodeIdx: number) => T): T[] {
168
- // let toExplore = [getRoot(tree)];
169
- // const results: T[] = []
170
- // let idx = 0;
171
- // while (toExplore.length) {
172
- // const nextLevel: TreeNode[] = [];
173
- // for (let i = 0; i < toExplore.length; i++) {
174
- // const node = toExplore[i];
175
- // if (node.left) {
176
- // nextLevel.push(node.left);
177
- // }
178
- // if (node.right) {
179
- // nextLevel.push(node.right);
180
- // }
181
- // results.push(iterFunc(node, idx));
182
- // idx++;
183
- // }
184
- // toExplore = nextLevel;
185
- // }
186
- // return results;
187
- // }
188
- /**
189
- * Creates the leaf node in a tree of empty leaves of height `level`.
190
- * Uses {@link CACHE_EMPTY_NODE} to efficiently produce
191
- * @param level
192
- * @returns
193
- */
194
- function emptyNode(level) {
195
- if (CACHE_EMPTY_NODE.has(level)) {
196
- return CACHE_EMPTY_NODE.get(level);
197
- }
198
- if (level == 0) {
199
- return Buffer.alloc(32);
200
- }
201
- let result = hash(emptyNode(level - 1), emptyNode(level - 1));
202
- CACHE_EMPTY_NODE.set(level, result);
203
- return result;
204
- }
205
- exports.emptyNode = emptyNode;
206
- /**
207
- * Helper function when creating a MerkleTree
208
- * @param level
209
- * @param id
210
- * @returns
211
- */
212
- function emptyTreeNode(level, id) {
213
- return {
214
- node: emptyNode(level),
215
- left: undefined,
216
- right: undefined,
217
- parent: undefined,
218
- level: level,
219
- id,
220
- };
221
- }
222
- /**
223
- * Helper function to build a MerkleTree
224
- * @param leaves
225
- * @returns
226
- */
227
- function buildLeaves(leaves) {
228
- let nodes = new Collections.Queue();
229
- let finalLeaves = [];
230
- leaves.forEach((buffer, index) => {
231
- if (buffer.length != exports.LEAF_BUFFER_LENGTH) {
232
- throw Error(`Provided leaf has length: ${buffer.length}, but we need all leaves to be length ${exports.LEAF_BUFFER_LENGTH}`);
233
- }
234
- const treeNode = {
235
- node: buffer,
236
- left: undefined,
237
- right: undefined,
238
- parent: undefined,
239
- level: 0,
240
- id: index,
241
- };
242
- nodes.enqueue(treeNode);
243
- finalLeaves.push(treeNode);
244
- });
245
- return [nodes, finalLeaves];
246
- }
247
- //# sourceMappingURL=merkleTree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merkleTree.js","sourceRoot":"","sources":["../../src/merkleTree.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA0B;AAC1B,oEAAsD;AACtD,6CAA4C;AAC5C,MAAM,EAAE,UAAU,EAAE,GAAG,iBAAG,CAAC;AAE3B,IAAI,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;AACpC,QAAA,kBAAkB,GAAW,EAAE,CAAC;AAS7C,MAAa,UAAU;IAKrB,YAAY,MAAgB;QAC1B,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAE3B,OAAO,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;YACvB,IAAI,IAAI,GAAG,KAAK,CAAC,OAAO,EAAG,CAAC;YAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YAEzB,IAAI,KAAe,CAAC;YACpB,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,EAAG,CAAC,KAAK,EAAE;gBAChC,KAAK,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBACrC,MAAM,EAAE,CAAC;aACV;iBAAM;gBACL,KAAK,GAAG,KAAK,CAAC,OAAO,EAAG,CAAC;aAC1B;YAED,IAAI,MAAM,GAAa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AAkB,EAAE,CACxG,CAAC;SACH;QAED,MAAM,QAAQ,GAAG;YACf,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,CAAC;YACR,EAAE,EAAE,KAAK;SACV,CAAC;QACF,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxB,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAC9B,CAAC"}
package/lib/cjs/pdas.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.blockKey = exports.lazySignerKey = exports.lazyTransactionsKey = void 0;
4
- const web3_js_1 = require("@solana/web3.js");
5
- const constants_1 = require("./constants");
6
- function lazyTransactionsKey(key, programId = constants_1.PROGRAM_ID) {
7
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("lazy_transactions", "utf-8"), Buffer.from(key, "utf-8")], programId);
8
- }
9
- exports.lazyTransactionsKey = lazyTransactionsKey;
10
- function lazySignerKey(key, programId = constants_1.PROGRAM_ID) {
11
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("lazy_signer", "utf-8"), Buffer.from(key, "utf-8")], programId);
12
- }
13
- exports.lazySignerKey = lazySignerKey;
14
- function blockKey(lazyTransactions, index, programId = constants_1.PROGRAM_ID) {
15
- const indexBuffer = Buffer.alloc(4);
16
- indexBuffer.writeUint32LE(index);
17
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("block", "utf-8"), lazyTransactions.toBuffer(), indexBuffer], programId);
18
- }
19
- exports.blockKey = blockKey;
20
- //# sourceMappingURL=pdas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pdas.js","sourceRoot":"","sources":["../../src/pdas.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAC5C,2CAAyC;AAEzC,SAAgB,mBAAmB,CACjC,GAAW,EACX,YAAuB,sBAAU;IAEjC,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EACtE,SAAS,CACV,CAAC;AACJ,CAAC;AARD,kDAQC;AAED,SAAgB,aAAa,CAC3B,GAAW,EACX,YAAuB,sBAAU;IAEjC,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,EAChE,SAAS,CACV,CAAC;AACJ,CAAC;AARD,sCAQC;AAED,SAAgB,QAAQ,CACtB,gBAA2B,EAC3B,KAAa,EACb,YAAuB,sBAAU;IAEjC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAChC,OAAO,mBAAS,CAAC,sBAAsB,CACrC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,QAAQ,EAAE,EAAE,WAAW,CAAC,EACzE,SAAS,CACV,CAAC;AACJ,CAAC;AAXD,4BAWC"}
@@ -1,3 +0,0 @@
1
- import { PublicKey } from "@solana/web3.js";
2
- export const PROGRAM_ID = new PublicKey("1atrmQs3eq1N2FEYWu6tyTXbCjP4uQwExpjtnhXtS8h");
3
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC"}