emblem-vault-sdk 2.9.0 → 2.9.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/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,7 +45,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
35
45
  const bignumber_1 = require("@ethersproject/bignumber");
36
46
  const utils_1 = require("./utils");
37
47
  const derive_1 = require("./derive");
38
- const SDK_VERSION = '2.9.0';
48
+ const constants_1 = require("./constants");
49
+ const vault_utils_1 = require("./vault-utils");
50
+ const evm_operations_1 = require("./evm-operations");
51
+ const SDK_VERSION = '2.9.2';
39
52
  class EmblemVaultSDK {
40
53
  constructor(apiKey, baseUrl, v3Url, sigUrl) {
41
54
  this.apiKey = apiKey;
@@ -80,8 +93,8 @@ class EmblemVaultSDK {
80
93
  }
81
94
  // ** Curated **
82
95
  //
83
- fetchCuratedContracts(hideUnMintable = false, overrideFunc = false) {
84
- return __awaiter(this, void 0, void 0, function* () {
96
+ fetchCuratedContracts() {
97
+ return __awaiter(this, arguments, void 0, function* (hideUnMintable = false, overrideFunc = false) {
85
98
  let url = `${this.baseUrl}/curated`;
86
99
  // Fetch using URL or override function
87
100
  let data = typeof overrideFunc === 'function' ? yield overrideFunc() : yield (0, utils_1.fetchData)(url, this.apiKey);
@@ -97,21 +110,21 @@ class EmblemVaultSDK {
97
110
  item[key] = template[key];
98
111
  });
99
112
  // Return a new object that combines the properties of the item and the template
100
- // return { ...item, ...template };
113
+ return Object.assign(Object.assign({}, item), template);
101
114
  return item;
102
115
  });
103
116
  return data;
104
117
  });
105
118
  }
106
- fetchCuratedContractByName(name, contracts = false) {
107
- return __awaiter(this, void 0, void 0, function* () {
119
+ fetchCuratedContractByName(name_1) {
120
+ return __awaiter(this, arguments, void 0, function* (name, contracts = false) {
108
121
  !contracts ? contracts = yield this.fetchCuratedContracts() : null;
109
122
  let contract = contracts.find((contract) => contract.name === name);
110
123
  return contract || null;
111
124
  });
112
125
  }
113
- createCuratedVault(template, callback = null) {
114
- return __awaiter(this, void 0, void 0, function* () {
126
+ createCuratedVault(template_1) {
127
+ return __awaiter(this, arguments, void 0, function* (template, callback = null) {
115
128
  (0, utils_1.templateGuard)(template);
116
129
  template.chainId == 1 ? delete template.targetContract[5] : delete template.targetContract[1];
117
130
  let url = `${this.baseUrl}/create-curated`;
@@ -119,14 +132,20 @@ class EmblemVaultSDK {
119
132
  callback(`creating Vault for user`, template.toAddress);
120
133
  }
121
134
  let vaultCreationResponse = yield (0, utils_1.fetchData)(url, this.apiKey, 'POST', template);
135
+ if (vaultCreationResponse === null || vaultCreationResponse === void 0 ? void 0 : vaultCreationResponse.err) {
136
+ if (callback)
137
+ callback(`error creating Vault: ${vaultCreationResponse.msg}`);
138
+ return vaultCreationResponse;
139
+ }
140
+ const { tokenId } = vaultCreationResponse.data;
122
141
  if (callback) {
123
- callback(`created Vault tokenId`, vaultCreationResponse.data.tokenId);
142
+ callback(`created Vault ${tokenId}`);
124
143
  }
125
144
  return vaultCreationResponse.data;
126
145
  });
127
146
  }
128
- refreshOwnershipForTokenId(tokenId, callback = null) {
129
- return __awaiter(this, void 0, void 0, function* () {
147
+ refreshOwnershipForTokenId(tokenId_1) {
148
+ return __awaiter(this, arguments, void 0, function* (tokenId, callback = null) {
130
149
  (0, utils_1.genericGuard)(tokenId, "string", "tokenId");
131
150
  let url = `${this.baseUrl}/refreshBalanceForTokenId`;
132
151
  let response = yield (0, utils_1.fetchData)(url, this.apiKey, 'POST', { tokenId });
@@ -136,8 +155,8 @@ class EmblemVaultSDK {
136
155
  return response;
137
156
  });
138
157
  }
139
- refreshOwnershipForAccount(account, callback = null) {
140
- return __awaiter(this, void 0, void 0, function* () {
158
+ refreshOwnershipForAccount(account_1) {
159
+ return __awaiter(this, arguments, void 0, function* (account, callback = null) {
141
160
  (0, utils_1.genericGuard)(account, "string", "account");
142
161
  let url = `${this.baseUrl}/refreshBalanceForAccount`;
143
162
  let response = yield (0, utils_1.fetchData)(url, this.apiKey, 'POST', { account });
@@ -147,8 +166,8 @@ class EmblemVaultSDK {
147
166
  return response;
148
167
  });
149
168
  }
150
- fetchMetadata(tokenId, callback = null) {
151
- return __awaiter(this, void 0, void 0, function* () {
169
+ fetchMetadata(tokenId_1) {
170
+ return __awaiter(this, arguments, void 0, function* (tokenId, callback = null) {
152
171
  (0, utils_1.genericGuard)(tokenId, "string", "tokenId");
153
172
  if (callback) {
154
173
  callback('getting Metadata');
@@ -161,8 +180,8 @@ class EmblemVaultSDK {
161
180
  return metadata;
162
181
  });
163
182
  }
164
- refreshBalance(tokenId, callback = null) {
165
- return __awaiter(this, void 0, void 0, function* () {
183
+ refreshBalance(tokenId_1) {
184
+ return __awaiter(this, arguments, void 0, function* (tokenId, callback = null) {
166
185
  (0, utils_1.genericGuard)(tokenId, "string", "tokenId");
167
186
  if (callback) {
168
187
  callback('refreshing Balance');
@@ -184,8 +203,8 @@ class EmblemVaultSDK {
184
203
  return vaults;
185
204
  });
186
205
  }
187
- generateJumpReport(address, hideUnMintable = false) {
188
- return __awaiter(this, void 0, void 0, function* () {
206
+ generateJumpReport(address_1) {
207
+ return __awaiter(this, arguments, void 0, function* (address, hideUnMintable = false) {
189
208
  let vaultType = "unclaimed";
190
209
  let curated = yield this.fetchCuratedContracts();
191
210
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
@@ -223,8 +242,8 @@ class EmblemVaultSDK {
223
242
  }));
224
243
  });
225
244
  }
226
- generateMintReport(address, hideUnMintable = false) {
227
- return __awaiter(this, void 0, void 0, function* () {
245
+ generateMintReport(address_1) {
246
+ return __awaiter(this, arguments, void 0, function* (address, hideUnMintable = false) {
228
247
  let vaults = yield this.fetchVaultsOfType("created", address);
229
248
  let curated = yield this.fetchCuratedContracts();
230
249
  let map = {};
@@ -255,8 +274,8 @@ class EmblemVaultSDK {
255
274
  }));
256
275
  });
257
276
  }
258
- generateMigrateReport(address, hideUnMintable = false) {
259
- return __awaiter(this, void 0, void 0, function* () {
277
+ generateMigrateReport(address_1) {
278
+ return __awaiter(this, arguments, void 0, function* (address, hideUnMintable = false) {
260
279
  let vaultType = "unclaimed";
261
280
  let curated = yield this.fetchCuratedContracts();
262
281
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
@@ -322,8 +341,8 @@ class EmblemVaultSDK {
322
341
  }
323
342
  });
324
343
  }
325
- performMintChain(web3, tokenId, collectionName, callback = null) {
326
- return __awaiter(this, void 0, void 0, function* () {
344
+ performMintChain(web3_1, tokenId_1, collectionName_1) {
345
+ return __awaiter(this, arguments, void 0, function* (web3, tokenId, collectionName, callback = null) {
327
346
  let collection = yield this.fetchCuratedContractByName(collectionName);
328
347
  let mintRequestSig = yield this.requestLocalMintSignature(web3, tokenId, callback);
329
348
  let remoteMintSig = yield this.requestRemoteMintSignature(web3, tokenId, mintRequestSig, callback);
@@ -333,16 +352,16 @@ class EmblemVaultSDK {
333
352
  return { mintResponse };
334
353
  });
335
354
  }
336
- performClaimChain(web3, tokenId, serialNumber, callback = null) {
337
- return __awaiter(this, void 0, void 0, function* () {
355
+ performClaimChain(web3_1, tokenId_1, serialNumber_1) {
356
+ return __awaiter(this, arguments, void 0, function* (web3, tokenId, serialNumber, callback = null) {
338
357
  let sig = yield this.requestLocalClaimSignature(web3, tokenId, serialNumber, callback);
339
358
  let jwt = yield this.requestRemoteClaimToken(web3, tokenId, sig, callback);
340
359
  let dkeys = yield this.requestRemoteKey(tokenId, jwt, callback);
341
360
  return yield this.decryptVaultKeys(tokenId, dkeys, callback);
342
361
  });
343
362
  }
344
- requestLocalMintSignature(web3, tokenId, callback = null) {
345
- return __awaiter(this, void 0, void 0, function* () {
363
+ requestLocalMintSignature(web3_1, tokenId_1) {
364
+ return __awaiter(this, arguments, void 0, function* (web3, tokenId, callback = null) {
346
365
  if (callback) {
347
366
  callback('requesting User Mint Signature');
348
367
  }
@@ -355,8 +374,8 @@ class EmblemVaultSDK {
355
374
  return signature;
356
375
  });
357
376
  }
358
- requestLocalClaimSignature(web3, tokenId, serialNumber, callback = null) {
359
- return __awaiter(this, void 0, void 0, function* () {
377
+ requestLocalClaimSignature(web3_1, tokenId_1, serialNumber_1) {
378
+ return __awaiter(this, arguments, void 0, function* (web3, tokenId, serialNumber, callback = null) {
360
379
  if (callback) {
361
380
  callback('requesting User Claim Signature');
362
381
  }
@@ -369,8 +388,8 @@ class EmblemVaultSDK {
369
388
  return signature;
370
389
  });
371
390
  }
372
- requestRemoteMintSignature(web3, tokenId, signature, callback = null) {
373
- return __awaiter(this, void 0, void 0, function* () {
391
+ requestRemoteMintSignature(web3_1, tokenId_1, signature_1) {
392
+ return __awaiter(this, arguments, void 0, function* (web3, tokenId, signature, callback = null) {
374
393
  if (callback) {
375
394
  callback('requesting Remote Mint signature');
376
395
  }
@@ -386,8 +405,8 @@ class EmblemVaultSDK {
386
405
  return remoteMintResponse;
387
406
  });
388
407
  }
389
- requestRemoteClaimToken(web3, tokenId, signature, callback = null) {
390
- return __awaiter(this, void 0, void 0, function* () {
408
+ requestRemoteClaimToken(web3_1, tokenId_1, signature_1) {
409
+ return __awaiter(this, arguments, void 0, function* (web3, tokenId, signature, callback = null) {
391
410
  if (callback) {
392
411
  callback('requesting Remote Claim token');
393
412
  }
@@ -400,8 +419,8 @@ class EmblemVaultSDK {
400
419
  return remoteClaimResponse;
401
420
  });
402
421
  }
403
- requestRemoteKey(tokenId, jwt, callback = null) {
404
- return __awaiter(this, void 0, void 0, function* () {
422
+ requestRemoteKey(tokenId_1, jwt_1) {
423
+ return __awaiter(this, arguments, void 0, function* (tokenId, jwt, callback = null) {
405
424
  if (callback) {
406
425
  callback('requesting Remote Key');
407
426
  }
@@ -412,8 +431,8 @@ class EmblemVaultSDK {
412
431
  return dkeys;
413
432
  });
414
433
  }
415
- decryptVaultKeys(tokenId, dkeys, callback = null) {
416
- return __awaiter(this, void 0, void 0, function* () {
434
+ decryptVaultKeys(tokenId_1, dkeys_1) {
435
+ return __awaiter(this, arguments, void 0, function* (tokenId, dkeys, callback = null) {
417
436
  if (callback) {
418
437
  callback('decrypting Vault Keys');
419
438
  }
@@ -425,8 +444,8 @@ class EmblemVaultSDK {
425
444
  return ukeys;
426
445
  });
427
446
  }
428
- getQuote(web3, amount, callback = null) {
429
- return __awaiter(this, void 0, void 0, function* () {
447
+ getQuote(web3_1, amount_1) {
448
+ return __awaiter(this, arguments, void 0, function* (web3, amount, callback = null) {
430
449
  if (callback) {
431
450
  callback('requesting Quote');
432
451
  }
@@ -439,8 +458,8 @@ class EmblemVaultSDK {
439
458
  return quote;
440
459
  });
441
460
  }
442
- performMint(web3, quote, remoteMintSig, callback = null) {
443
- return __awaiter(this, void 0, void 0, function* () {
461
+ performMint(web3_1, quote_1, remoteMintSig_1) {
462
+ return __awaiter(this, arguments, void 0, function* (web3, quote, remoteMintSig, callback = null) {
444
463
  // async performMint(web3, quote, remoteMintSig, callback = null) {
445
464
  if (callback) {
446
465
  callback('performing Mint');
@@ -477,8 +496,8 @@ class EmblemVaultSDK {
477
496
  return mintResponse;
478
497
  });
479
498
  }
480
- performBurn(web3, tokenId, callback = null) {
481
- return __awaiter(this, void 0, void 0, function* () {
499
+ performBurn(web3_1, tokenId_1) {
500
+ return __awaiter(this, arguments, void 0, function* (web3, tokenId, callback = null) {
482
501
  let metadata = yield this.fetchMetadata(tokenId);
483
502
  let targetContract = yield this.fetchCuratedContractByName(metadata.targetContract.name);
484
503
  if (callback) {
@@ -539,20 +558,20 @@ class EmblemVaultSDK {
539
558
  }));
540
559
  });
541
560
  }
542
- checkLiveliness(tokenId, chainId = 1) {
543
- return __awaiter(this, void 0, void 0, function* () {
561
+ checkLiveliness(tokenId_1) {
562
+ return __awaiter(this, arguments, void 0, function* (tokenId, chainId = 1) {
544
563
  let url = `${this.baseUrl}/liveliness-curated/`;
545
564
  return yield (0, utils_1.fetchData)(url, this.apiKey, 'POST', { tokenId: tokenId }, { chainid: chainId, "Content-Type": "application/json" });
546
565
  });
547
566
  }
548
- checkLivelinessBulk(tokenIds, chainId = 1) {
549
- return __awaiter(this, void 0, void 0, function* () {
567
+ checkLivelinessBulk(tokenIds_1) {
568
+ return __awaiter(this, arguments, void 0, function* (tokenIds, chainId = 1) {
550
569
  const chunkSize = 20;
551
570
  let results = [];
552
571
  let url = `${this.baseUrl}/batch_liveliness/`;
553
572
  let apiKey = this.apiKey;
554
- function processChunks(i = 0, delay = 1000) {
555
- return __awaiter(this, void 0, void 0, function* () {
573
+ function processChunks() {
574
+ return __awaiter(this, arguments, void 0, function* (i = 0, delay = 1000) {
556
575
  if (i < tokenIds.length) {
557
576
  let chunk = tokenIds.slice(i, i + chunkSize);
558
577
  try {
@@ -571,9 +590,53 @@ class EmblemVaultSDK {
571
590
  return results;
572
591
  });
573
592
  }
593
+ // ========================================================================
594
+ // Remote Signer Methods (EmblemVaultClient) - Multi-Chain Support
595
+ // ========================================================================
596
+ getSdkContext() {
597
+ return {
598
+ apiKey: this.apiKey,
599
+ baseUrl: this.baseUrl,
600
+ v3Url: this.v3Url,
601
+ sigUrl: this.sigUrl,
602
+ fetchMetadata: this.fetchMetadata.bind(this),
603
+ requestRemoteKey: this.requestRemoteKey.bind(this),
604
+ decryptVaultKeys: this.decryptVaultKeys.bind(this),
605
+ };
606
+ }
607
+ performMintChainWithClient(client_1, tokenId_1) {
608
+ return __awaiter(this, arguments, void 0, function* (client, tokenId, chainId = constants_1.ETHEREUM_MAINNET_CHAIN_ID, callback) {
609
+ (0, utils_1.genericGuard)(tokenId, "string", "tokenId");
610
+ (0, vault_utils_1.getChainConfig)(chainId);
611
+ return (0, evm_operations_1.performMintEvm)(this.getSdkContext(), client, tokenId, chainId, callback);
612
+ });
613
+ }
614
+ performClaimChainWithClient(client_1, tokenId_1) {
615
+ return __awaiter(this, arguments, void 0, function* (client, tokenId, chainId = constants_1.ETHEREUM_MAINNET_CHAIN_ID, callback) {
616
+ var _a, _b;
617
+ (0, utils_1.genericGuard)(tokenId, "string", "tokenId");
618
+ (0, vault_utils_1.getChainConfig)(chainId);
619
+ callback === null || callback === void 0 ? void 0 : callback('Fetching vault metadata...');
620
+ const metadata = yield this.fetchMetadata(tokenId, callback);
621
+ const claimIdentifier = (0, vault_utils_1.getClaimIdentifier)(metadata);
622
+ // Check if this is a V2 vault by checking the deployment type (matches VaultActions.vue logic)
623
+ // metadata[chainId]?.type?.endsWith('V2') indicates a diamond/V2 contract
624
+ const deploymentInfo = metadata === null || metadata === void 0 ? void 0 : metadata[chainId];
625
+ const vaultIsV2 = Boolean((_b = (_a = deploymentInfo === null || deploymentInfo === void 0 ? void 0 : deploymentInfo.type) === null || _a === void 0 ? void 0 : _a.endsWith) === null || _b === void 0 ? void 0 : _b.call(_a, 'V2'));
626
+ const needsOnChainUnvault = (0, vault_utils_1.requiresOnChainUnvault)(metadata) && vaultIsV2;
627
+ return (0, evm_operations_1.performClaimEvm)(this.getSdkContext(), client, tokenId, chainId, metadata, claimIdentifier, vaultIsV2, needsOnChainUnvault, callback);
628
+ });
629
+ }
630
+ deleteVaultWithClient(client_1, tokenId_1) {
631
+ return __awaiter(this, arguments, void 0, function* (client, tokenId, chainId = constants_1.ETHEREUM_MAINNET_CHAIN_ID, callback) {
632
+ (0, utils_1.genericGuard)(tokenId, "string", "tokenId");
633
+ (0, vault_utils_1.getChainConfig)(chainId);
634
+ return (0, evm_operations_1.deleteVaultEvm)(client, tokenId, chainId, callback);
635
+ });
636
+ }
574
637
  // BTC
575
- sweepVaultUsingPhrase(phrase, satsPerByte = 20, broadcast = false) {
576
- return __awaiter(this, void 0, void 0, function* () {
638
+ sweepVaultUsingPhrase(phrase_1) {
639
+ return __awaiter(this, arguments, void 0, function* (phrase, satsPerByte = 20, broadcast = false) {
577
640
  const { paymentAddress, paymentPublicKey, ordinalsAddress } = yield (0, utils_1.getSatsConnectAddress)();
578
641
  // change this to mainnet
579
642
  if (window.bitcoin) {
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildMintMessage = buildMintMessage;
4
+ exports.buildClaimMessage = buildClaimMessage;
5
+ exports.buildUnvaultMessage = buildUnvaultMessage;
6
+ exports.buildDeleteMessage = buildDeleteMessage;
7
+ function buildMintMessage(tokenId) {
8
+ return `Curated Minting: ${tokenId}`;
9
+ }
10
+ function buildClaimMessage(identifier, isV2Vault) {
11
+ const prefix = isV2Vault ? 'Unvault' : 'Claim';
12
+ return `${prefix}: ${identifier}`;
13
+ }
14
+ function buildUnvaultMessage(identifier) {
15
+ return `Unvault: ${identifier}`;
16
+ }
17
+ function buildDeleteMessage(tokenId) {
18
+ return `Delete: ${tokenId}`;
19
+ }
package/dist/utils.js CHANGED
@@ -12,7 +12,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.signPSBT = exports.getSatsConnectAddress = exports.decryptKeys = exports.getTorusKeys = exports.COIN_TO_NETWORK = exports.checkContentType = exports.getLegacyContract = exports.getHandlerContract = exports.getQuoteContractObject = exports.genericGuard = exports.templateGuard = exports.generateTemplate = exports.generateImageTemplate = exports.generateAttributeTemplate = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
15
+ exports.COIN_TO_NETWORK = exports.fetchData = exports.metadataAllProjects = exports.metadataObj2Arr = exports.evaluateFacts = exports.pad = exports.NFT_DATA = void 0;
16
+ exports.generateAttributeTemplate = generateAttributeTemplate;
17
+ exports.generateImageTemplate = generateImageTemplate;
18
+ exports.generateTemplate = generateTemplate;
19
+ exports.templateGuard = templateGuard;
20
+ exports.genericGuard = genericGuard;
21
+ exports.getQuoteContractObject = getQuoteContractObject;
22
+ exports.getHandlerContract = getHandlerContract;
23
+ exports.getLegacyContract = getLegacyContract;
24
+ exports.checkContentType = checkContentType;
25
+ exports.getTorusKeys = getTorusKeys;
26
+ exports.decryptKeys = decryptKeys;
27
+ exports.getSatsConnectAddress = getSatsConnectAddress;
28
+ exports.signPSBT = signPSBT;
29
+ exports.parseBigIntValue = parseBigIntValue;
16
30
  const crypto_js_1 = __importDefault(require("crypto-js"));
17
31
  const metadata_json_1 = __importDefault(require("./curated/metadata.json"));
18
32
  const darkfarms_metadata_json_1 = __importDefault(require("./curated/darkfarms-metadata.json"));
@@ -68,7 +82,7 @@ const metadataAllProjects = (projects) => projects.reduce((unique, item) => {
68
82
  return unique;
69
83
  }, []);
70
84
  exports.metadataAllProjects = metadataAllProjects;
71
- const fetchData = (url, apiKey, method = 'GET', body = null, headers = null) => __awaiter(void 0, void 0, void 0, function* () {
85
+ const fetchData = (url_1, apiKey_1, ...args_1) => __awaiter(void 0, [url_1, apiKey_1, ...args_1], void 0, function* (url, apiKey, method = 'GET', body = null, headers = null) {
72
86
  const options = {
73
87
  method: method,
74
88
  headers: headers ? Object.assign(Object.assign({}, headers), { 'x-api-key': apiKey }) : { 'x-api-key': apiKey },
@@ -260,7 +274,6 @@ function generateAttributeTemplate(record) {
260
274
  }
261
275
  return template;
262
276
  }
263
- exports.generateAttributeTemplate = generateAttributeTemplate;
264
277
  function generateImageTemplate(record) {
265
278
  let template = {};
266
279
  if (record.imageHandler) {
@@ -282,7 +295,6 @@ function generateImageTemplate(record) {
282
295
  }
283
296
  return template;
284
297
  }
285
- exports.generateImageTemplate = generateImageTemplate;
286
298
  /**
287
299
  * generateTemplate defines rules and utilitites for a given curated
288
300
  * collection. This is used by callers, like emblem.finance website
@@ -585,6 +597,39 @@ function generateTemplate(record) {
585
597
  nameAndImage.description = nameAndImage.description + viewOnEmblemFinanceLink;
586
598
  return nameAndImage;
587
599
  },
600
+ fillCreateVaultTemplate: (args, _this) => {
601
+ const template = _this.generateCreateTemplate(_this);
602
+ if (args.fromAddress) {
603
+ template.fromAddress = args.fromAddress;
604
+ }
605
+ else {
606
+ throw new Error("fromAddress is required to create vault");
607
+ }
608
+ if (args.toAddress) {
609
+ template.toAddress = args.toAddress;
610
+ }
611
+ else {
612
+ throw new Error("toAddress is required to create vault");
613
+ }
614
+ if (args.chainId) {
615
+ const chainIdAsString = String(args.chainId);
616
+ template.targetContract = {
617
+ name: template.targetContract.name,
618
+ [chainIdAsString]: template.targetContract[chainIdAsString]
619
+ };
620
+ template.chainId = args.chainId;
621
+ }
622
+ else {
623
+ throw new Error("chainId is required to create vault");
624
+ }
625
+ if (args.targetAsset) {
626
+ Object.assign(template.targetAsset, args.targetAsset);
627
+ }
628
+ else {
629
+ template.targetAsset = undefined;
630
+ }
631
+ return template;
632
+ },
588
633
  generateCreateTemplate: (_this) => {
589
634
  let template = {
590
635
  fromAddress: { type: "user-provided" },
@@ -627,7 +672,6 @@ function generateTemplate(record) {
627
672
  });
628
673
  return template;
629
674
  }
630
- exports.generateTemplate = generateTemplate;
631
675
  function templateGuard(input) {
632
676
  if (!input)
633
677
  throw new Error(`No template provided`);
@@ -662,14 +706,12 @@ function templateGuard(input) {
662
706
  }
663
707
  }
664
708
  }
665
- exports.templateGuard = templateGuard;
666
709
  function genericGuard(input, type, key) {
667
710
  if (!input)
668
711
  throw new Error(`No ${key} provided`);
669
712
  if (typeof input !== type)
670
713
  throw new Error(`Invalid ${key} provided`);
671
714
  }
672
- exports.genericGuard = genericGuard;
673
715
  function getQuoteContractObject(web3) {
674
716
  return __awaiter(this, void 0, void 0, function* () {
675
717
  let contractAddress = '0xE5dec92911c78069d727a67C85936EDDbc9B02Cf';
@@ -677,7 +719,6 @@ function getQuoteContractObject(web3) {
677
719
  return quoteContract;
678
720
  });
679
721
  }
680
- exports.getQuoteContractObject = getQuoteContractObject;
681
722
  function getHandlerContract(web3) {
682
723
  return __awaiter(this, void 0, void 0, function* () {
683
724
  let contractAddress = '0x23859b51117dbFBcdEf5b757028B18d7759a4460';
@@ -685,7 +726,6 @@ function getHandlerContract(web3) {
685
726
  return handlerContract;
686
727
  });
687
728
  }
688
- exports.getHandlerContract = getHandlerContract;
689
729
  function getLegacyContract(web3) {
690
730
  return __awaiter(this, void 0, void 0, function* () {
691
731
  let contractAddress = '0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab';
@@ -693,7 +733,6 @@ function getLegacyContract(web3) {
693
733
  return handlerContract;
694
734
  });
695
735
  }
696
- exports.getLegacyContract = getLegacyContract;
697
736
  function checkContentType(url) {
698
737
  return new Promise((resolve, reject) => {
699
738
  let returnVal = { valid: false };
@@ -743,7 +782,6 @@ function checkContentType(url) {
743
782
  });
744
783
  });
745
784
  }
746
- exports.checkContentType = checkContentType;
747
785
  // export function checkContentType(url: string) {
748
786
  // return new Promise((resolve, reject) => {
749
787
  // // Making a HTTP HEAD request to get only the headers
@@ -858,8 +896,8 @@ const mimeToExtensionMap = {
858
896
  "video/vnd.dlna.mpeg-tts": ".ts"
859
897
  // Add more mappings if needed
860
898
  };
861
- function getTorusKeys(verifierId, idToken, cb = null) {
862
- return __awaiter(this, void 0, void 0, function* () {
899
+ function getTorusKeys(verifierId_1, idToken_1) {
900
+ return __awaiter(this, arguments, void 0, function* (verifierId, idToken, cb = null) {
863
901
  const FetchNodeDetails = require("@toruslabs/fetch-node-details").default;
864
902
  const TorusUtils = require("@toruslabs/torus.js").default;
865
903
  const fetchNodeDetails = new FetchNodeDetails();
@@ -869,7 +907,6 @@ function getTorusKeys(verifierId, idToken, cb = null) {
869
907
  return { privateKey: privKey };
870
908
  });
871
909
  }
872
- exports.getTorusKeys = getTorusKeys;
873
910
  function decryptKeys(vaultCiphertextV2, keys, addresses) {
874
911
  return __awaiter(this, void 0, void 0, function* () {
875
912
  try {
@@ -887,7 +924,6 @@ function decryptKeys(vaultCiphertextV2, keys, addresses) {
887
924
  }
888
925
  });
889
926
  }
890
- exports.decryptKeys = decryptKeys;
891
927
  function getSatsConnectAddress() {
892
928
  return __awaiter(this, void 0, void 0, function* () {
893
929
  return new Promise((resolve, reject) => {
@@ -918,9 +954,8 @@ function getSatsConnectAddress() {
918
954
  });
919
955
  });
920
956
  }
921
- exports.getSatsConnectAddress = getSatsConnectAddress;
922
- function signPSBT(psbtBase64, paymentAddress, indexes, broadcast = false) {
923
- return __awaiter(this, void 0, void 0, function* () {
957
+ function signPSBT(psbtBase64_1, paymentAddress_1, indexes_1) {
958
+ return __awaiter(this, arguments, void 0, function* (psbtBase64, paymentAddress, indexes, broadcast = false) {
924
959
  return new Promise((resolve, reject) => {
925
960
  (0, sats_connect_1.signTransaction)({
926
961
  payload: {
@@ -951,4 +986,9 @@ function signPSBT(psbtBase64, paymentAddress, indexes, broadcast = false) {
951
986
  });
952
987
  });
953
988
  }
954
- exports.signPSBT = signPSBT;
989
+ function parseBigIntValue(value) {
990
+ if (typeof value === 'object' && value !== null && 'hex' in value) {
991
+ return BigInt(value.hex);
992
+ }
993
+ return BigInt(String(value));
994
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isV2Vault = isV2Vault;
4
+ exports.requiresOnChainUnvault = requiresOnChainUnvault;
5
+ exports.getClaimIdentifier = getClaimIdentifier;
6
+ exports.getHandlerContractAddress = getHandlerContractAddress;
7
+ exports.getUnvaultingContractAddress = getUnvaultingContractAddress;
8
+ exports.getChainConfig = getChainConfig;
9
+ exports.isEvmChain = isEvmChain;
10
+ const constants_1 = require("./constants");
11
+ function isV2Vault(metadata) {
12
+ var _a;
13
+ return Boolean((_a = metadata.targetContract) === null || _a === void 0 ? void 0 : _a.name);
14
+ }
15
+ function requiresOnChainUnvault(metadata) {
16
+ return metadata.status === 'unclaimed' && !metadata.sealed && Boolean(metadata.live);
17
+ }
18
+ /**
19
+ * Get the claim identifier for signing claim messages.
20
+ * This MUST match VaultActions.vue's getSerialNumber() logic:
21
+ * - ERC1155: use targetContract.serialNumber
22
+ * - ERC721a: use tokenId
23
+ * - Legacy: use tokenId
24
+ */
25
+ function getClaimIdentifier(metadata) {
26
+ const { targetContract, ownershipInfo, tokenId } = metadata;
27
+ // If no targetContract, fallback to tokenId
28
+ if (!targetContract) {
29
+ return tokenId || '';
30
+ }
31
+ // ERC1155: use serialNumber
32
+ if (targetContract.collectionType === 'ERC1155' ||
33
+ (ownershipInfo === null || ownershipInfo === void 0 ? void 0 : ownershipInfo.category) === 'erc1155') {
34
+ return targetContract.serialNumber || tokenId || '';
35
+ }
36
+ // ERC721a: use tokenId (NOT serialNumber!)
37
+ if (targetContract.collectionType === 'ERC721a' ||
38
+ (ownershipInfo === null || ownershipInfo === void 0 ? void 0 : ownershipInfo.category) === 'erc721a') {
39
+ return tokenId || '';
40
+ }
41
+ // Default: use targetContract.tokenId or tokenId
42
+ return targetContract.tokenId || tokenId || '';
43
+ }
44
+ function getHandlerContractAddress(chainId) {
45
+ const config = getChainConfig(chainId);
46
+ if (!config.handlerContract) {
47
+ throw new Error(`No handler contract configured for chain ${chainId}`);
48
+ }
49
+ return config.handlerContract;
50
+ }
51
+ function getUnvaultingContractAddress(chainId) {
52
+ const config = getChainConfig(chainId);
53
+ if (!config.unvaultingContract) {
54
+ throw new Error(`No unvaulting contract configured for chain ${chainId}`);
55
+ }
56
+ return config.unvaultingContract;
57
+ }
58
+ function getChainConfig(chainId) {
59
+ const config = constants_1.SUPPORTED_CHAINS[chainId];
60
+ if (!config) {
61
+ const supportedList = Object.entries(constants_1.SUPPORTED_CHAINS)
62
+ .map(([id, cfg]) => `${cfg.name} (${id})`)
63
+ .join(', ');
64
+ throw new Error(`Unsupported chain: ${chainId}. Supported chains: ${supportedList}`);
65
+ }
66
+ return config;
67
+ }
68
+ function isEvmChain(chainId) {
69
+ const config = constants_1.SUPPORTED_CHAINS[chainId];
70
+ return (config === null || config === void 0 ? void 0 : config.type) === 'evm';
71
+ }