@buildonspark/issuer-sdk 0.0.59 → 0.0.60

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/types.cjs CHANGED
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
6
  var __copyProps = (to, from, except, desc) => {
11
7
  if (from && typeof from === "object" || typeof from === "function") {
12
8
  for (let key of __getOwnPropNames(from))
@@ -19,12 +15,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
15
 
20
16
  // src/types.ts
21
17
  var types_exports = {};
22
- __export(types_exports, {
23
- LayerType: () => LayerType,
24
- OnChainTransactionStatus: () => OnChainTransactionStatus,
25
- OperationType: () => OperationType,
26
- SparkTransactionStatus: () => SparkTransactionStatus
27
- });
28
18
  module.exports = __toCommonJS(types_exports);
29
19
 
30
20
  // buffer.js
@@ -35,43 +25,3 @@ if (typeof globalThis.Buffer === "undefined") {
35
25
  if (typeof global === "undefined") {
36
26
  window.global = window.globalThis;
37
27
  }
38
-
39
- // src/types.ts
40
- var LayerType = /* @__PURE__ */ ((LayerType2) => {
41
- LayerType2["L1"] = "L1";
42
- LayerType2["SPARK"] = "SPARK";
43
- return LayerType2;
44
- })(LayerType || {});
45
- var OperationType = /* @__PURE__ */ ((OperationType2) => {
46
- OperationType2["USER_TRANSFER"] = "USER_TRANSFER";
47
- OperationType2["USER_BURN"] = "USER_BURN";
48
- OperationType2["ISSUER_ANNOUNCE"] = "ISSUER_ANNOUNCE";
49
- OperationType2["ISSUER_MINT"] = "ISSUER_MINT";
50
- OperationType2["ISSUER_TRANSFER"] = "ISSUER_TRANSFER";
51
- OperationType2["ISSUER_FREEZE"] = "ISSUER_FREEZE";
52
- OperationType2["ISSUER_UNFREEZE"] = "ISSUER_UNFREEZE";
53
- OperationType2["ISSUER_BURN"] = "ISSUER_BURN";
54
- return OperationType2;
55
- })(OperationType || {});
56
- var OnChainTransactionStatus = /* @__PURE__ */ ((OnChainTransactionStatus2) => {
57
- OnChainTransactionStatus2["PENDING"] = "PENDING";
58
- OnChainTransactionStatus2["CONFIRMED"] = "CONFIRMED";
59
- OnChainTransactionStatus2["WAITING_MINED"] = "WAITING_MINED";
60
- OnChainTransactionStatus2["MINED"] = "MINED";
61
- OnChainTransactionStatus2["ATTACHING"] = "ATTACHING";
62
- OnChainTransactionStatus2["ATTACHED"] = "ATTACHED";
63
- return OnChainTransactionStatus2;
64
- })(OnChainTransactionStatus || {});
65
- var SparkTransactionStatus = /* @__PURE__ */ ((SparkTransactionStatus2) => {
66
- SparkTransactionStatus2["STARTED"] = "STARTED";
67
- SparkTransactionStatus2["SIGNED"] = "SIGNED";
68
- SparkTransactionStatus2["FINALIZED"] = "FINALIZED";
69
- return SparkTransactionStatus2;
70
- })(SparkTransactionStatus || {});
71
- // Annotate the CommonJS export names for ESM import in node:
72
- 0 && (module.exports = {
73
- LayerType,
74
- OnChainTransactionStatus,
75
- OperationType,
76
- SparkTransactionStatus
77
- });
package/dist/types.d.cts CHANGED
@@ -1,31 +1,4 @@
1
- declare enum LayerType {
2
- L1 = "L1",
3
- SPARK = "SPARK"
4
- }
5
- declare enum OperationType {
6
- USER_TRANSFER = "USER_TRANSFER",
7
- USER_BURN = "USER_BURN",
8
- ISSUER_ANNOUNCE = "ISSUER_ANNOUNCE",
9
- ISSUER_MINT = "ISSUER_MINT",
10
- ISSUER_TRANSFER = "ISSUER_TRANSFER",
11
- ISSUER_FREEZE = "ISSUER_FREEZE",
12
- ISSUER_UNFREEZE = "ISSUER_UNFREEZE",
13
- ISSUER_BURN = "ISSUER_BURN"
14
- }
15
- declare enum OnChainTransactionStatus {
16
- PENDING = "PENDING",
17
- CONFIRMED = "CONFIRMED",
18
- WAITING_MINED = "WAITING_MINED",
19
- MINED = "MINED",
20
- ATTACHING = "ATTACHING",
21
- ATTACHED = "ATTACHED"
22
- }
23
- declare enum SparkTransactionStatus {
24
- STARTED = "STARTED",
25
- SIGNED = "SIGNED",
26
- FINALIZED = "FINALIZED"
27
- }
28
- type GetTokenActivityResponse = {
1
+ type TokenActivityResponse = {
29
2
  transactions: Transaction[];
30
3
  nextCursor?: ListAllTokenTransactionsCursor | undefined;
31
4
  };
@@ -59,19 +32,19 @@ interface OnChainTokenOutput {
59
32
  tokenAmount?: string | undefined;
60
33
  }
61
34
  interface OnChainTransaction {
62
- operationType: OperationType;
35
+ operationType: string;
63
36
  transactionHash: string;
64
37
  rawtx: string;
65
- status: OnChainTransactionStatus;
38
+ status: string;
66
39
  inputs: OnChainTokenOutput[];
67
40
  outputs: OnChainTokenOutput[];
68
41
  broadcastedAt: Date | undefined;
69
42
  confirmedAt: Date | undefined;
70
43
  }
71
44
  interface SparkTransaction {
72
- operationType: OperationType;
45
+ operationType: string;
73
46
  transactionHash: string;
74
- status: SparkTransactionStatus;
47
+ status: string;
75
48
  confirmedAt: Date | undefined;
76
49
  leavesToCreate: SparkLeaf[];
77
50
  leavesToSpend: SparkLeaf[];
@@ -93,7 +66,7 @@ interface SparkLeaf {
93
66
  }
94
67
  interface ListAllTokenTransactionsCursor {
95
68
  lastTransactionHash: string;
96
- layer: LayerType;
69
+ layer: string;
97
70
  }
98
71
  interface TokenDistribution {
99
72
  totalCirculatingSupply: bigint;
@@ -103,4 +76,4 @@ interface TokenDistribution {
103
76
  numConfirmedTransactions: bigint;
104
77
  }
105
78
 
106
- export { type GetTokenActivityResponse, LayerType, type ListAllTokenTransactionsCursor, type OnChainTokenOutput, type OnChainTransaction, OnChainTransactionStatus, OperationType, type SparkLeaf, type SparkTransaction, SparkTransactionStatus, type TokenDistribution, type TokenPubKeyInfoResponse, type Transaction };
79
+ export type { ListAllTokenTransactionsCursor, OnChainTokenOutput, OnChainTransaction, SparkLeaf, SparkTransaction, TokenActivityResponse, TokenDistribution, TokenPubKeyInfoResponse, Transaction };
package/dist/types.d.ts CHANGED
@@ -1,31 +1,4 @@
1
- declare enum LayerType {
2
- L1 = "L1",
3
- SPARK = "SPARK"
4
- }
5
- declare enum OperationType {
6
- USER_TRANSFER = "USER_TRANSFER",
7
- USER_BURN = "USER_BURN",
8
- ISSUER_ANNOUNCE = "ISSUER_ANNOUNCE",
9
- ISSUER_MINT = "ISSUER_MINT",
10
- ISSUER_TRANSFER = "ISSUER_TRANSFER",
11
- ISSUER_FREEZE = "ISSUER_FREEZE",
12
- ISSUER_UNFREEZE = "ISSUER_UNFREEZE",
13
- ISSUER_BURN = "ISSUER_BURN"
14
- }
15
- declare enum OnChainTransactionStatus {
16
- PENDING = "PENDING",
17
- CONFIRMED = "CONFIRMED",
18
- WAITING_MINED = "WAITING_MINED",
19
- MINED = "MINED",
20
- ATTACHING = "ATTACHING",
21
- ATTACHED = "ATTACHED"
22
- }
23
- declare enum SparkTransactionStatus {
24
- STARTED = "STARTED",
25
- SIGNED = "SIGNED",
26
- FINALIZED = "FINALIZED"
27
- }
28
- type GetTokenActivityResponse = {
1
+ type TokenActivityResponse = {
29
2
  transactions: Transaction[];
30
3
  nextCursor?: ListAllTokenTransactionsCursor | undefined;
31
4
  };
@@ -59,19 +32,19 @@ interface OnChainTokenOutput {
59
32
  tokenAmount?: string | undefined;
60
33
  }
61
34
  interface OnChainTransaction {
62
- operationType: OperationType;
35
+ operationType: string;
63
36
  transactionHash: string;
64
37
  rawtx: string;
65
- status: OnChainTransactionStatus;
38
+ status: string;
66
39
  inputs: OnChainTokenOutput[];
67
40
  outputs: OnChainTokenOutput[];
68
41
  broadcastedAt: Date | undefined;
69
42
  confirmedAt: Date | undefined;
70
43
  }
71
44
  interface SparkTransaction {
72
- operationType: OperationType;
45
+ operationType: string;
73
46
  transactionHash: string;
74
- status: SparkTransactionStatus;
47
+ status: string;
75
48
  confirmedAt: Date | undefined;
76
49
  leavesToCreate: SparkLeaf[];
77
50
  leavesToSpend: SparkLeaf[];
@@ -93,7 +66,7 @@ interface SparkLeaf {
93
66
  }
94
67
  interface ListAllTokenTransactionsCursor {
95
68
  lastTransactionHash: string;
96
- layer: LayerType;
69
+ layer: string;
97
70
  }
98
71
  interface TokenDistribution {
99
72
  totalCirculatingSupply: bigint;
@@ -103,4 +76,4 @@ interface TokenDistribution {
103
76
  numConfirmedTransactions: bigint;
104
77
  }
105
78
 
106
- export { type GetTokenActivityResponse, LayerType, type ListAllTokenTransactionsCursor, type OnChainTokenOutput, type OnChainTransaction, OnChainTransactionStatus, OperationType, type SparkLeaf, type SparkTransaction, SparkTransactionStatus, type TokenDistribution, type TokenPubKeyInfoResponse, type Transaction };
79
+ export type { ListAllTokenTransactionsCursor, OnChainTokenOutput, OnChainTransaction, SparkLeaf, SparkTransaction, TokenActivityResponse, TokenDistribution, TokenPubKeyInfoResponse, Transaction };
package/dist/types.js CHANGED
@@ -1,12 +1 @@
1
- import {
2
- LayerType,
3
- OnChainTransactionStatus,
4
- OperationType,
5
- SparkTransactionStatus
6
- } from "./chunk-GB7N6I5O.js";
7
- export {
8
- LayerType,
9
- OnChainTransactionStatus,
10
- OperationType,
11
- SparkTransactionStatus
12
- };
1
+ import "./chunk-77FPZDAE.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildonspark/issuer-sdk",
3
- "version": "0.0.59",
3
+ "version": "0.0.60",
4
4
  "description": "Spark Issuer SDK for token issuance",
5
5
  "license": "Apache-2.0",
6
6
  "module": "./dist/index.js",
@@ -15,6 +15,14 @@
15
15
  "./types": {
16
16
  "import": "./dist/types.js",
17
17
  "require": "./dist/types.cjs"
18
+ },
19
+ "./proto/spark": {
20
+ "import": "./dist/proto/spark.js",
21
+ "require": "./dist/proto/spark.cjs"
22
+ },
23
+ "./proto/lrc20": {
24
+ "import": "./dist/proto/lrc20.js",
25
+ "require": "./dist/proto/lrc20.cjs"
18
26
  }
19
27
  },
20
28
  "browser": {
@@ -54,15 +62,13 @@
54
62
  "generate:proto": "PATH=\"$PATH:./node_modules/.bin\" protoc --ts_proto_out=./src/proto --ts_proto_opt=outputServices=nice-grpc,useExactTypes=false,outputServices=generic-definitions,oneof=unions,importSuffix=.js --proto_path=../../../../protos spark.proto mock.proto spark_authn.proto && yarn format:fix"
55
63
  },
56
64
  "dependencies": {
57
- "@bufbuild/protobuf": "^2.2.5",
58
- "@buildonspark/lrc20-sdk": "0.0.51",
59
- "@buildonspark/spark-sdk": "0.1.28",
65
+ "@buildonspark/lrc20-sdk": "0.0.52",
66
+ "@buildonspark/spark-sdk": "0.1.29",
60
67
  "@lightsparkdev/core": "^1.4.0",
61
68
  "@noble/curves": "^1.8.0",
62
69
  "@scure/btc-signer": "^1.5.0",
63
70
  "bitcoinjs-lib": "^6.1.5",
64
71
  "buffer": "^6.0.3",
65
- "nice-grpc-common": "^2.0.2",
66
72
  "ts-proto": "^2.6.1"
67
73
  },
68
74
  "devDependencies": {
@@ -1,8 +1,4 @@
1
1
  import { TokenPubkey, TokenPubkeyAnnouncement } from "@buildonspark/lrc20-sdk";
2
- import {
3
- ListAllTokenTransactionsCursor,
4
- OperationType,
5
- } from "@buildonspark/lrc20-sdk/proto/rpc/v1/types";
6
2
  import {
7
3
  NetworkError,
8
4
  SparkWallet,
@@ -15,6 +11,7 @@ import {
15
11
  encodeSparkAddress,
16
12
  } from "@buildonspark/spark-sdk/address";
17
13
  import { OutputWithPreviousTransactionData } from "@buildonspark/spark-sdk/proto/spark";
14
+ import { Layer } from "@buildonspark/spark-sdk/proto/lrc20";
18
15
  import { ConfigOptions } from "@buildonspark/spark-sdk/services/wallet-config";
19
16
  import {
20
17
  bytesToHex,
@@ -23,9 +20,13 @@ import {
23
20
  } from "@noble/curves/abstract/utils";
24
21
  import { TokenFreezeService } from "./services/freeze.js";
25
22
  import { IssuerTokenTransactionService } from "./services/token-transactions.js";
26
- import { GetTokenActivityResponse, TokenDistribution } from "./types.js";
27
- import { convertTokenActivityToHexEncoded } from "./utils/type-mappers.js";
23
+ import { TokenActivityResponse, TokenDistribution } from "./types.js";
24
+ import { convertToTokenActivity } from "./utils/type-mappers.js";
28
25
  import { NotImplementedError } from "@buildonspark/spark-sdk";
26
+ import {
27
+ ListAllTokenTransactionsCursor,
28
+ OperationType,
29
+ } from "@buildonspark/spark-sdk/proto/lrc20";
29
30
 
30
31
  const BURN_ADDRESS = "02".repeat(33);
31
32
 
@@ -36,6 +37,7 @@ export type IssuerTokenInfo = {
36
37
  tokenDecimals: number;
37
38
  maxSupply: bigint;
38
39
  isFreezable: boolean;
40
+ totalSupply: bigint;
39
41
  };
40
42
 
41
43
  /**
@@ -163,6 +165,7 @@ export class IssuerSparkWallet extends SparkWallet {
163
165
  tokenDecimals: Number(bytesToNumberBE(info.announcement!.decimal)),
164
166
  isFreezable: info.announcement!.isFreezable,
165
167
  maxSupply: bytesToNumberBE(info.announcement!.maxSupply),
168
+ totalSupply: bytesToNumberBE(info.totalSupply),
166
169
  };
167
170
  } catch (error) {
168
171
  throw new NetworkError("Failed to get token info", {
@@ -281,11 +284,14 @@ export class IssuerSparkWallet extends SparkWallet {
281
284
  */
282
285
  public async getIssuerTokenActivity(
283
286
  pageSize: number = 100,
284
- cursor?: ListAllTokenTransactionsCursor,
285
- operationTypes?: OperationType[],
287
+ cursor?: {
288
+ lastTransactionHash: string | Uint8Array;
289
+ layer: string | Layer;
290
+ },
291
+ operationTypes?: string[] | OperationType[],
286
292
  beforeTimestamp?: Date,
287
293
  afterTimestamp?: Date,
288
- ): Promise<GetTokenActivityResponse> {
294
+ ): Promise<TokenActivityResponse> {
289
295
  if (!Number.isSafeInteger(pageSize)) {
290
296
  throw new ValidationError("pageSize must be less than 2^53", {
291
297
  field: "pageSize",
@@ -296,17 +302,78 @@ export class IssuerSparkWallet extends SparkWallet {
296
302
 
297
303
  const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
298
304
 
305
+ // Convert cursor to proper ListAllTokenTransactionsCursor format
306
+ let convertedCursor: ListAllTokenTransactionsCursor | undefined;
307
+ if (cursor) {
308
+ const lastTransactionHash =
309
+ typeof cursor.lastTransactionHash === "string"
310
+ ? hexToBytes(cursor.lastTransactionHash)
311
+ : cursor.lastTransactionHash;
312
+
313
+ let layer: Layer;
314
+ if (typeof cursor.layer === "string") {
315
+ switch (cursor.layer.toUpperCase()) {
316
+ case "L1":
317
+ layer = Layer.L1;
318
+ break;
319
+ case "Spark":
320
+ layer = Layer.SPARK;
321
+ break;
322
+ default:
323
+ layer = Layer.UNRECOGNIZED;
324
+ }
325
+ } else {
326
+ layer = cursor.layer;
327
+ }
328
+
329
+ convertedCursor = {
330
+ lastTransactionHash,
331
+ layer,
332
+ };
333
+ }
334
+
335
+ // Convert operationTypes to proper OperationType[] format
336
+ let convertedOperationTypes: OperationType[] | undefined;
337
+ if (operationTypes) {
338
+ if (typeof operationTypes[0] === "string") {
339
+ convertedOperationTypes = (operationTypes as string[]).map((opType) => {
340
+ switch (opType.toUpperCase()) {
341
+ case "USER_TRANSFER":
342
+ return OperationType.USER_TRANSFER;
343
+ case "USER_BURN":
344
+ return OperationType.USER_BURN;
345
+ case "ISSUER_ANNOUNCE":
346
+ return OperationType.ISSUER_ANNOUNCE;
347
+ case "ISSUER_MINT":
348
+ return OperationType.ISSUER_MINT;
349
+ case "ISSUER_TRANSFER":
350
+ return OperationType.ISSUER_TRANSFER;
351
+ case "ISSUER_FREEZE":
352
+ return OperationType.ISSUER_FREEZE;
353
+ case "ISSUER_UNFREEZE":
354
+ return OperationType.ISSUER_UNFREEZE;
355
+ case "ISSUER_BURN":
356
+ return OperationType.ISSUER_BURN;
357
+ default:
358
+ return OperationType.UNRECOGNIZED;
359
+ }
360
+ });
361
+ } else {
362
+ convertedOperationTypes = operationTypes as OperationType[];
363
+ }
364
+ }
365
+
299
366
  try {
300
367
  const transactions = await lrc20Client.listTransactions({
301
368
  tokenPublicKey: hexToBytes(await super.getIdentityPublicKey()),
302
- cursor,
369
+ cursor: convertedCursor,
303
370
  pageSize,
304
371
  beforeTimestamp,
305
372
  afterTimestamp,
306
- operationTypes,
373
+ operationTypes: convertedOperationTypes,
307
374
  });
308
375
 
309
- return convertTokenActivityToHexEncoded(transactions);
376
+ return convertToTokenActivity(transactions);
310
377
  } catch (error) {
311
378
  throw new NetworkError("Failed to get token activity", {
312
379
  operation: "listTransactions",
@@ -0,0 +1 @@
1
+ export * from "@buildonspark/spark-sdk/proto/lrc20";