@1money/protocol-ts-sdk 1.0.16 → 1.1.0

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.
Files changed (39) hide show
  1. package/.claude/settings.local.json +14 -2
  2. package/.env.integration.example +19 -0
  3. package/AGENTS.md +28 -0
  4. package/LICENSE +21 -0
  5. package/README.md +21 -55
  6. package/es/__integration__/config.d.ts +24 -0
  7. package/es/__integration__/helpers.d.ts +75 -0
  8. package/es/__integration__/setup.d.ts +26 -0
  9. package/es/api/accounts/index.d.ts +7 -1
  10. package/es/api/accounts/types.d.ts +4 -2
  11. package/es/api/checkpoints/index.d.ts +7 -1
  12. package/es/api/checkpoints/types.d.ts +4 -16
  13. package/es/api/index.js +45 -4
  14. package/es/api/tokens/index.d.ts +13 -1
  15. package/es/api/tokens/types.d.ts +27 -9
  16. package/es/api/transactions/index.d.ts +7 -2
  17. package/es/api/transactions/types.d.ts +149 -2
  18. package/es/client/core.d.ts +1 -1
  19. package/es/client/index.js +3 -3
  20. package/es/index.js +58 -8
  21. package/es/utils/index.js +13 -4
  22. package/lib/__integration__/config.d.ts +24 -0
  23. package/lib/__integration__/helpers.d.ts +75 -0
  24. package/lib/__integration__/setup.d.ts +26 -0
  25. package/lib/api/accounts/index.d.ts +7 -1
  26. package/lib/api/accounts/types.d.ts +4 -2
  27. package/lib/api/checkpoints/index.d.ts +7 -1
  28. package/lib/api/checkpoints/types.d.ts +4 -16
  29. package/lib/api/index.js +47 -6
  30. package/lib/api/tokens/index.d.ts +13 -1
  31. package/lib/api/tokens/types.d.ts +27 -9
  32. package/lib/api/transactions/index.d.ts +7 -2
  33. package/lib/api/transactions/types.d.ts +149 -2
  34. package/lib/client/core.d.ts +1 -1
  35. package/lib/client/index.js +5 -5
  36. package/lib/index.js +60 -10
  37. package/lib/utils/index.js +13 -4
  38. package/package.json +10 -1
  39. package/umd/1money-protocol-ts-sdk.min.js +2 -2
@@ -7,8 +7,20 @@
7
7
  "Bash(grep:*)",
8
8
  "Bash(sed:*)",
9
9
  "Bash(npm test)",
10
- "Bash(npx tsc:*)"
10
+ "Bash(npx tsc:*)",
11
+ "Bash(./node_modules/.bin/tsc:*)",
12
+ "Bash(npm install:*)",
13
+ "Bash(npm run lint)",
14
+ "Bash(npm run test:integration:*)",
15
+ "Bash(node -e:*)",
16
+ "Bash(npm run test:integration:testnet:*)",
17
+ "Bash(node test-sig.mjs:*)",
18
+ "Bash(xargs grep -l recent_epoch|recent_checkpoint|recentEpoch|recentCheckpoint)",
19
+ "Bash(cat:*)",
20
+ "Bash(xargs grep:*)",
21
+ "Bash(npm run lint:es_fix:*)",
22
+ "Bash(node test-encoding.mjs:*)"
11
23
  ],
12
24
  "deny": []
13
25
  }
14
- }
26
+ }
@@ -0,0 +1,19 @@
1
+ # Integration Test Environment Variables
2
+ # Copy this file to .env.integration and update with your values
3
+
4
+ # Enable integration tests
5
+ RUN_INTEGRATION_TESTS=true
6
+
7
+ # Network configuration (local, testnet, mainnet)
8
+ INTEGRATION_TEST_NETWORK=local
9
+
10
+ # Operator private key (for transaction signing)
11
+ # Default: Local test key
12
+ INTEGRATION_TEST_OPERATOR_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
13
+
14
+ # Master account private key (for token management)
15
+ # Default: Local test key
16
+ INTEGRATION_TEST_MASTER_KEY=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
17
+
18
+ # Test timeout in milliseconds
19
+ INTEGRATION_TEST_TIMEOUT=120000
package/AGENTS.md ADDED
@@ -0,0 +1,28 @@
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+ Core TypeScript sources live in `src/`, with domain folders for `api/`, `client/`, and shared `utils/`. Entry points such as `src/index.ts` stitch those modules together, while accompanying specs sit in sibling `__test__` directories (`src/api/tokens/__test__/index.test.ts`, etc.). Compiled artifacts are emitted to `es/` (ESM), `lib/` (CJS), and `umd/` for CDN usage, so never edit those outputs directly. Reference assets reside in `public/`, examples in `examples/`, and longer-form docs in `docs/`. Build behavior is centralized in `omni.config.js`, bundling tweaks in `rollup.config.js`, and TypeScript settings in `tsconfig.json`.
5
+
6
+ ## Build, Test & Development Commands
7
+ Use your preferred package manager, but stay consistent per branch.
8
+ ```bash
9
+ pnpm install # or npm install – install dev + peer tooling
10
+ npm run build # omni build -> emits es/lib/umd bundles
11
+ npm run build:remote # same build with RUN_ENV=remote for hosted targets
12
+ npm test # nyc + mocha using .mocharc.js
13
+ npm run lint # prettier check + eslint (ts/tsx)
14
+ npm run lint:fix # applies prettier/eslint autofixes
15
+ ```
16
+ Run linting before opening a PR; CI expects clean output directories.
17
+
18
+ ## Coding Style & Naming Conventions
19
+ The repo enforces `.editorconfig` (LF, UTF-8, two-space indents) and `prettier.config.js` (tabWidth 2, printWidth 50, single quotes, arrowParens `avoid`, trailing commas `none`). ESLint runs with `@typescript-eslint` rules over `src/**`. Prefer descriptive module exports (`api/checkpoints`, `client/rpc`) and keep test files named `*.test.ts`. Public APIs should expose camelCase functions, PascalCase classes, and never leak internal helper names.
20
+
21
+ ## Testing Guidelines
22
+ All specs use Mocha + Chai and live beside their subjects (`__test__/`). Structure tests as `describe('<module>')` blocks with explicit success/error cases that mirror the SDK’s `.success/.timeout/.error` flow. Execute `npm test` locally; NYC writes reports to `.nyc_output/` and enforces the existing coverage baselines, so add scenarios rather than loosening thresholds. When adding a module, stub network calls and favor deterministic fixtures.
23
+
24
+ ## Commit & Pull Request Guidelines
25
+ Commitlint extends the conventional config with allowed types such as `feat`, `fix`, `docs`, `refactor`, `test`, `chore`, plus the project tag `[1MONEY-PROTOCOL-TS-SDK]`. Format messages as `type(scope): summary`, e.g., `feat(api): add token metadata endpoint`. Before pushing, run `npm run lint && npm test` and ensure generated bundles are excluded from diffs. PRs should describe the change, list validation commands, link related issues, and include API or screenshot evidence when touching user-facing behavior.
26
+
27
+ ## Security & Configuration Tips
28
+ Never commit `.env` values; tests should rely on mocked data or public endpoints. When debugging against live protocol nodes, set `RUN_ENV=remote` only in your shell and prefer the `testnet` client configuration shown in `README.md`. Audit dependencies before enabling new wallets or transports, and keep peer versions (`axios`, `viem`, `@ethereumjs/rlp`) aligned with the ranges declared in `package.json`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 1Money Co.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -4,10 +4,10 @@
4
4
  The TS-SDK for 1Money Network Protocol
5
5
 
6
6
  [![Build Status](https://github.com/1Money-Co/1money-protocol-ts-sdk/actions/workflows/cicd-npm.yml/badge.svg)](https://github.com/1Money-Co/1money-protocol-ts-sdk/actions/workflows/cicd-npm.yml)
7
- [![NPM downloads](http://img.shields.io/npm/dm/%401money%2Fts-sdk.svg?style=flat-square)](https://www.npmjs.com/package/@1money/protocol-ts-sdk)
8
- [![npm version](https://badge.fury.io/js/%401money%2Fts-sdk.svg)](https://badge.fury.io/js/%401money%2Fts-sdk)
9
- [![install size](https://packagephobia.now.sh/badge?p=%401money%2Fts-sdk)](https://packagephobia.now.sh/result?p=%401money%2Fts-sdk)
10
- [![license](http://img.shields.io/npm/l/%401money%2Fts-sdk.svg)](https://github.com/1money/tpls/blob/master/packages/ts-sdk/LICENSE)
7
+ [![NPM downloads](http://img.shields.io/npm/dm/%401money%2Fprotocol-ts-sdk.svg?style=flat-square)](https://www.npmjs.com/package/@1money/protocol-ts-sdk)
8
+ [![npm version](https://badge.fury.io/js/%401money%2Fprotocol-ts-sdk.svg)](https://badge.fury.io/js/%401money%2Fprotocol-ts-sdk)
9
+ [![install size](https://packagephobia.now.sh/badge?p=%401money%2Fprotocol-ts-sdk)](https://packagephobia.now.sh/result?p=%401money%2Fprotocol-ts-sdk)
10
+ [![license](http://img.shields.io/npm/l/%401money%2Fprotocol-ts-sdk.svg)](https://github.com/1Money-Co/1money-protocol-ts-sdk/blob/main/LICENSE)
11
11
 
12
12
  ## Quick start
13
13
  ### Install
@@ -151,24 +151,6 @@ apiClient.someMethod()
151
151
 
152
152
  ## API Methods
153
153
 
154
- ### State API
155
-
156
- #### Get Latest Epoch Checkpoint
157
- The state API provides access to the latest epoch and checkpoint values that are required for all POST operations. The response includes both the epoch/checkpoint numbers and their cryptographic hashes.
158
-
159
- ```typescript
160
- apiClient.state.getLatestEpochCheckpoint()
161
- .success(response => {
162
- console.log('Latest epoch:', response.epoch);
163
- console.log('Latest checkpoint:', response.checkpoint);
164
- console.log('Checkpoint hash:', response.checkpoint_hash);
165
- console.log('Parent checkpoint hash:', response.checkpoint_parent_hash);
166
- })
167
- .error(err => {
168
- console.error('Error:', err);
169
- });
170
- ```
171
-
172
154
  ### Chain API
173
155
 
174
156
  #### Get Chain ID
@@ -236,8 +218,6 @@ const epochData = await apiClient.state.getLatestEpochCheckpoint()
236
218
 
237
219
  // Create the payload array for signing
238
220
  const payload = [
239
- epochData.epoch, // recent_epoch
240
- epochData.checkpoint, // recent_checkpoint
241
221
  1, // chain_id
242
222
  1, // nonce
243
223
  'MTK', // symbol
@@ -253,10 +233,8 @@ if (!signature) {
253
233
  throw new Error('Failed to generate signature');
254
234
  }
255
235
 
256
- // Create the issue payload with epoch checkpoint data
236
+ // Create the issue payload
257
237
  const issuePayload = {
258
- recent_epoch: epochData.epoch,
259
- recent_checkpoint: epochData.checkpoint,
260
238
  chain_id: 1,
261
239
  nonce: 1,
262
240
  name: 'My Token',
@@ -290,8 +268,6 @@ const epochData = await apiClient.state.getLatestEpochCheckpoint()
290
268
 
291
269
  // Create the payload array for signing
292
270
  const payload = [
293
- epochData.epoch, // recent_epoch
294
- epochData.checkpoint, // recent_checkpoint
295
271
  1, // chain_id
296
272
  1, // nonce
297
273
  ManageListAction.Add, // action
@@ -305,10 +281,8 @@ if (!signature) {
305
281
  throw new Error('Failed to generate signature');
306
282
  }
307
283
 
308
- // Create the manage list payload with epoch checkpoint data
284
+ // Create the manage list payload
309
285
  const manageListPayload = {
310
- recent_epoch: epochData.epoch,
311
- recent_checkpoint: epochData.checkpoint,
312
286
  chain_id: 1,
313
287
  nonce: 1,
314
288
  action: ManageListAction.Add,
@@ -349,12 +323,11 @@ const epochData = await apiClient.state.getLatestEpochCheckpoint()
349
323
 
350
324
  // Create the payload array for signing
351
325
  const payload = [
352
- epochData.epoch, // recent_epoch
353
- epochData.checkpoint, // recent_checkpoint
354
326
  1, // chain_id
355
327
  1, // nonce
356
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
328
+ '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // recipient (for burn, same as sender)
357
329
  '1000000000000000000', // amount
330
+ '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
358
331
  ];
359
332
 
360
333
  // Generate signature
@@ -363,14 +336,13 @@ if (!signature) {
363
336
  throw new Error('Failed to generate signature');
364
337
  }
365
338
 
366
- // Create the burn payload with epoch checkpoint data
339
+ // Create the burn payload
367
340
  const burnPayload = {
368
- recent_epoch: epochData.epoch,
369
- recent_checkpoint: epochData.checkpoint,
370
341
  chain_id: 1,
371
342
  nonce: 1,
372
- token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
343
+ recipient: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
373
344
  value: '1000000000000000000',
345
+ token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
374
346
  signature
375
347
  };
376
348
 
@@ -397,14 +369,13 @@ const epochData = await apiClient.state.getLatestEpochCheckpoint()
397
369
 
398
370
  // Create the payload array for signing
399
371
  const payload = [
400
- epochData.epoch, // recent_epoch
401
- epochData.checkpoint, // recent_checkpoint
402
372
  1, // chain_id
403
373
  1, // nonce
404
- '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
405
- '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3', // authority_address
406
374
  AuthorityAction.Grant, // action
407
- AuthorityType.MasterMint, // authority_type
375
+ AuthorityType.MasterMint, // authority_type (sends 'MasterMintBurn')
376
+ '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3', // authority_address
377
+ '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // token
378
+ '1000000000000000000000', // value (optional, for MintBurnTokens type)
408
379
  ];
409
380
 
410
381
  // Generate signature
@@ -413,16 +384,15 @@ if (!signature) {
413
384
  throw new Error('Failed to generate signature');
414
385
  }
415
386
 
416
- // Create the authority payload with epoch checkpoint data
387
+ // Create the authority payload
417
388
  const authorityPayload = {
418
- recent_epoch: epochData.epoch,
419
- recent_checkpoint: epochData.checkpoint,
420
389
  chain_id: 1,
421
390
  nonce: 1,
422
- token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
423
- authority_address: '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3',
424
391
  action: AuthorityAction.Grant,
425
- authority_type: AuthorityType.MasterMint,
392
+ authority_type: AuthorityType.MasterMint, // value is 'MasterMintBurn'
393
+ authority_address: '0x9E1E9688A44D058fF181Ed64ddFAFbBE5CC74ff3',
394
+ token: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
395
+ value: '1000000000000000000000',
426
396
  signature
427
397
  };
428
398
 
@@ -489,8 +459,6 @@ const epochData = await apiClient.state.getLatestEpochCheckpoint()
489
459
 
490
460
  // Create the payload array for signing
491
461
  const payload = [
492
- epochData.epoch, // recent_epoch
493
- epochData.checkpoint, // recent_checkpoint
494
462
  1, // chain_id
495
463
  1, // nonce
496
464
  '0x2cd8999Be299373D7881f4aDD11510030ad1412F', // recipient
@@ -504,10 +472,8 @@ if (!signature) {
504
472
  throw new Error('Failed to generate signature');
505
473
  }
506
474
 
507
- // Create the payment payload with epoch checkpoint data
475
+ // Create the payment payload
508
476
  const paymentPayload = {
509
- recent_epoch: epochData.epoch,
510
- recent_checkpoint: epochData.checkpoint,
511
477
  chain_id: 1,
512
478
  nonce: 1,
513
479
  recipient: '0x2cd8999Be299373D7881f4aDD11510030ad1412F',
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Integration test configuration
3
+ *
4
+ * Environment variables:
5
+ * - INTEGRATION_TEST_NETWORK: Network to use (local, testnet, mainnet)
6
+ * - INTEGRATION_TEST_OPERATOR_KEY: Operator private key
7
+ * - INTEGRATION_TEST_MASTER_KEY: Master account private key
8
+ * - RUN_INTEGRATION_TESTS: Set to 'true' to run integration tests
9
+ */
10
+ export interface IntegrationTestConfig {
11
+ network: 'local' | 'testnet' | 'mainnet';
12
+ operatorKey: string;
13
+ masterKey: string;
14
+ enabled: boolean;
15
+ timeout: number;
16
+ }
17
+ /**
18
+ * Get integration test configuration from environment variables
19
+ */
20
+ export declare function getConfig(): IntegrationTestConfig;
21
+ /**
22
+ * Check if integration tests should run
23
+ */
24
+ export declare function shouldRunIntegrationTests(): boolean;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Integration test helper utilities
3
+ */
4
+ import type { RestSignature } from '../api/tokens/types';
5
+ import type { TestAccount } from './setup';
6
+ import type { Payload } from '../utils/interface';
7
+ /**
8
+ * Create API client for integration tests
9
+ */
10
+ export declare function createTestClient(): {
11
+ accounts: typeof import("../api/accounts").accountsApi;
12
+ checkpoints: typeof import("../api/checkpoints").checkpointsApi;
13
+ tokens: typeof import("../api/tokens").tokensApi;
14
+ transactions: typeof import("../api/transactions").transactionsApi;
15
+ chain: typeof import("../api/chain").chainApi;
16
+ };
17
+ /**
18
+ * Sign a payload with an account and return RestSignature format
19
+ */
20
+ export declare function signPayload(payload: Payload, account: TestAccount): Promise<RestSignature>;
21
+ /**
22
+ * Wait for a transaction to be finalized
23
+ * @param txHash Transaction hash
24
+ * @param maxRetries Maximum number of retries
25
+ * @param retryDelay Delay between retries in milliseconds
26
+ */
27
+ export declare function waitForFinalization(txHash: string, maxRetries?: number, retryDelay?: number): Promise<boolean>;
28
+ /**
29
+ * Wait for a specific amount of time
30
+ */
31
+ export declare function wait(ms: number): Promise<void>;
32
+ /**
33
+ * Get current checkpoint number
34
+ */
35
+ export declare function getCurrentCheckpoint(): Promise<number>;
36
+ /**
37
+ * Get account nonce
38
+ */
39
+ export declare function getAccountNonce(address: string): Promise<number>;
40
+ /**
41
+ * Get chain ID
42
+ */
43
+ export declare function getChainId(): Promise<number>;
44
+ /**
45
+ * Derive token address from owner and nonce
46
+ */
47
+ export declare function deriveTokenAddress(owner: string, nonce: number): string;
48
+ /**
49
+ * Assert that a value is defined (throws if undefined/null)
50
+ */
51
+ export declare function assertDefined<T>(value: T | undefined | null, message?: string): asserts value is T;
52
+ /**
53
+ * Format test section header
54
+ */
55
+ export declare function logSection(title: string): void;
56
+ /**
57
+ * Format test step log
58
+ */
59
+ export declare function logStep(step: string, detail?: string): void;
60
+ /**
61
+ * Generate a random token symbol for testing
62
+ */
63
+ export declare function generateRandomSymbol(prefix?: string): string;
64
+ /**
65
+ * Normalize an address to checksum format for comparison
66
+ */
67
+ export declare function normalizeAddress(address: string): string;
68
+ /**
69
+ * Check if two addresses are equal (case-insensitive)
70
+ */
71
+ export declare function addressEquals(addr1: string, addr2: string): boolean;
72
+ /**
73
+ * Check if an array of addresses includes a specific address (case-insensitive)
74
+ */
75
+ export declare function addressArrayIncludes(addresses: string[], targetAddress: string): boolean;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Integration test setup and account generation
3
+ */
4
+ import type { PrivateKeyAccount } from 'viem/accounts';
5
+ export interface TestAccount extends PrivateKeyAccount {
6
+ privateKey: `0x${string}`;
7
+ }
8
+ export interface TestAccounts {
9
+ operator: TestAccount;
10
+ master: TestAccount;
11
+ user1: TestAccount;
12
+ user2: TestAccount;
13
+ user3: TestAccount;
14
+ }
15
+ /**
16
+ * Generate and cache test accounts
17
+ */
18
+ export declare function getTestAccounts(): TestAccounts;
19
+ /**
20
+ * Log test account information
21
+ */
22
+ export declare function logTestAccounts(): void;
23
+ /**
24
+ * Reset test accounts (for cleanup)
25
+ */
26
+ export declare function resetTestAccounts(): void;
@@ -1,4 +1,4 @@
1
- import type { AccountInfo, AssociatedTokenAccount } from './types';
1
+ import type { AccountInfo, AssociatedTokenAccount, BbNonceInfo } from './types';
2
2
  /**
3
3
  * Accounts API methods
4
4
  */
@@ -9,6 +9,12 @@ export declare const accountsApi: {
9
9
  * @returns Promise with account info response
10
10
  */
11
11
  getNonce: (address: string) => import("../../client/index.js").PromiseWrapper<"custom", AccountInfo, AccountInfo, AccountInfo, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | AccountInfo, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<AccountInfo>;
12
+ /**
13
+ * Get account bbnonce
14
+ * @param address Address of the account to lookup nonce for
15
+ * @returns Promise with bbnonce info response
16
+ */
17
+ getBbNonce: (address: string) => import("../../client/index.js").PromiseWrapper<"custom", BbNonceInfo, BbNonceInfo, BbNonceInfo, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | BbNonceInfo, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<BbNonceInfo>;
12
18
  /**
13
19
  * Get associated token account
14
20
  * @param address Address of the account to lookup associated token account for
@@ -1,9 +1,11 @@
1
- import { AddressSchema, U256Schema } from '../types';
1
+ import { U256Schema } from '../types';
2
2
  export interface AccountInfo {
3
3
  nonce: number;
4
4
  }
5
+ export interface BbNonceInfo {
6
+ bbnonce: number;
7
+ }
5
8
  export interface AssociatedTokenAccount {
6
- token_account_address: AddressSchema;
7
9
  balance: U256Schema;
8
10
  nonce: number;
9
11
  }
@@ -1,4 +1,4 @@
1
- import type { CheckpointNumberResponse, Checkpoint } from './types';
1
+ import type { Checkpoint, CheckpointNumberResponse, CheckpointReceipts } from './types';
2
2
  /**
3
3
  * Checkpoint API methods
4
4
  */
@@ -22,5 +22,11 @@ export declare const checkpointsApi: {
22
22
  * @returns Promise with checkpoint response
23
23
  */
24
24
  getByNumber: (number: number | string, full?: boolean) => import("../../client/index.js").PromiseWrapper<"custom", Checkpoint, Checkpoint, Checkpoint, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Checkpoint, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Checkpoint>;
25
+ /**
26
+ * Get checkpoint receipts by number
27
+ * @param number Number of the checkpoint to lookup
28
+ * @returns Promise with checkpoint receipts response
29
+ */
30
+ getReceiptsByNumber: (number: number | string) => import("../../client/index.js").PromiseWrapper<"custom", CheckpointReceipts, CheckpointReceipts, CheckpointReceipts, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | CheckpointReceipts, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<CheckpointReceipts>;
25
31
  };
26
32
  export default checkpointsApi;
@@ -1,22 +1,9 @@
1
- import { B256Schema, AddressSchema } from '../types';
1
+ import { B256Schema } from '../types';
2
+ import type { Transaction, TransactionReceipt } from '../transactions/types';
2
3
  export interface CheckpointNumberResponse {
3
4
  number: number;
4
5
  }
5
- export interface Transaction {
6
- hash: B256Schema;
7
- chain_id: number;
8
- from: AddressSchema;
9
- nonce: number;
10
- fee: number;
11
- signature: {
12
- r: string;
13
- s: string;
14
- v: number;
15
- };
16
- checkpoint_hash?: B256Schema;
17
- checkpoint_number?: number;
18
- transaction_index?: number;
19
- }
6
+ export type { Transaction };
20
7
  export interface Header {
21
8
  hash: B256Schema;
22
9
  parent_hash: B256Schema;
@@ -31,3 +18,4 @@ export interface Checkpoint extends Header {
31
18
  size?: number;
32
19
  transactions: Transaction[] | B256Schema[];
33
20
  }
21
+ export type CheckpointReceipts = TransactionReceipt[];
package/es/api/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import axios$1 from'axios';import'viem';import'@ethereumjs/rlp';function _typeof(ele) {
1
+ import'viem';import'@ethereumjs/rlp';import axios$1 from'axios';function _typeof(ele) {
2
2
  if (typeof ele !== 'object')
3
3
  return (typeof ele).toLowerCase();
4
4
  const typeStr = Object.prototype.toString.call(ele);
@@ -261,9 +261,9 @@ class Request {
261
261
  if (isTimeout)
262
262
  return;
263
263
  cleanup();
264
- console.error(`[1Money client]: Error(${err.status ?? 500}, ${err.code ?? 'UNKNOWN'}), Message: ${err.message}, Config: ${err.config?.method}, ${err.config?.baseURL ?? ''}${err.config?.url ?? ''}, ${JSON.stringify(err.config?.headers ?? {})}, Request: ${JSON.stringify(err.config?.data ?? {})};`);
265
- const status = err.response?.status ?? 500;
266
264
  const data = err.response?.data ?? {};
265
+ console.error(`[1Money client]: Error(${err.status ?? 500}, ${err.code ?? 'UNKNOWN'}), Message: ${err.message}, Config: ${err.config?.method}, ${err.config?.baseURL ?? ''}${err.config?.url ?? ''}, ${JSON.stringify(err.config?.headers ?? {})}, Request: ${JSON.stringify(err.config?.data ?? {})}, Response: ${JSON.stringify(data)};`);
266
+ const status = err.response?.status ?? 500;
267
267
  const headers = err.response?.headers ?? {};
268
268
  try {
269
269
  let res = data;
@@ -329,6 +329,14 @@ const accountsApi = {
329
329
  getNonce: (address) => {
330
330
  return get(`${API_PREFIX$4}/nonce?address=${address}`, { withCredentials: false });
331
331
  },
332
+ /**
333
+ * Get account bbnonce
334
+ * @param address Address of the account to lookup nonce for
335
+ * @returns Promise with bbnonce info response
336
+ */
337
+ getBbNonce: (address) => {
338
+ return get(`${API_PREFIX$4}/bbnonce?address=${address}`, { withCredentials: false });
339
+ },
332
340
  /**
333
341
  * Get associated token account
334
342
  * @param address Address of the account to lookup associated token account for
@@ -367,6 +375,14 @@ const checkpointsApi = {
367
375
  */
368
376
  getByNumber: (number, full = false) => {
369
377
  return get(`${API_PREFIX$3}/by_number?number=${number}&full=${full}`, { withCredentials: false });
378
+ },
379
+ /**
380
+ * Get checkpoint receipts by number
381
+ * @param number Number of the checkpoint to lookup
382
+ * @returns Promise with checkpoint receipts response
383
+ */
384
+ getReceiptsByNumber: (number) => {
385
+ return get(`${API_PREFIX$3}/receipts/by_number?number=${number}`, { withCredentials: false });
370
386
  }
371
387
  };const API_PREFIX$2 = `/${API_VERSION}/tokens`;
372
388
  /**
@@ -444,6 +460,22 @@ const tokensApi = {
444
460
  */
445
461
  updateMetadata: (payload) => {
446
462
  return post(`${API_PREFIX$2}/update_metadata`, payload, { withCredentials: false });
463
+ },
464
+ /**
465
+ * Bridge and mint tokens
466
+ * @param payload Token bridge and mint request payload
467
+ * @returns Promise with transaction hash response
468
+ */
469
+ bridgeAndMint: (payload) => {
470
+ return post(`${API_PREFIX$2}/bridge_and_mint`, payload, { withCredentials: false });
471
+ },
472
+ /**
473
+ * Burn and bridge tokens
474
+ * @param payload Token burn and bridge request payload
475
+ * @returns Promise with transaction hash response
476
+ */
477
+ burnAndBridge: (payload) => {
478
+ return post(`${API_PREFIX$2}/burn_and_bridge`, payload, { withCredentials: false });
447
479
  }
448
480
  };const API_PREFIX$1 = `/${API_VERSION}/transactions`;
449
481
  /**
@@ -466,6 +498,14 @@ const transactionsApi = {
466
498
  getReceiptByHash: (hash) => {
467
499
  return get(`${API_PREFIX$1}/receipt/by_hash?hash=${hash}`, { withCredentials: false });
468
500
  },
501
+ /**
502
+ * Get finalized transaction by hash
503
+ * @param hash Hash of the transaction to lookup
504
+ * @returns Promise with finalized transaction receipt response
505
+ */
506
+ getFinalizedByHash: (hash) => {
507
+ return get(`${API_PREFIX$1}/finalized/by_hash?hash=${hash}`, { withCredentials: false });
508
+ },
469
509
  /**
470
510
  * Estimate transaction fee
471
511
  * @param from Address of the transaction author
@@ -503,11 +543,12 @@ const chainApi = {
503
543
  };// Authority types
504
544
  var AuthorityType;
505
545
  (function (AuthorityType) {
506
- AuthorityType["MasterMint"] = "MasterMint";
546
+ AuthorityType["MasterMint"] = "MasterMintBurn";
507
547
  AuthorityType["MintBurnTokens"] = "MintBurnTokens";
508
548
  AuthorityType["Pause"] = "Pause";
509
549
  AuthorityType["ManageList"] = "ManageList";
510
550
  AuthorityType["UpdateMetadata"] = "UpdateMetadata";
551
+ AuthorityType["Bridge"] = "Bridge";
511
552
  })(AuthorityType || (AuthorityType = {}));
512
553
  var AuthorityAction;
513
554
  (function (AuthorityAction) {
@@ -1,5 +1,5 @@
1
1
  import type { Hash, HashWithToken } from '../../api/types';
2
- import type { MintInfo, TokenManageListPayload, TokenBurnPayload, TokenAuthorityPayload, TokenIssuePayload, TokenMintPayload, TokenPausePayload, TokenMetadataPayload } from './types';
2
+ import type { MintInfo, TokenManageListPayload, TokenBurnPayload, TokenAuthorityPayload, TokenIssuePayload, TokenMintPayload, TokenPausePayload, TokenMetadataPayload, TokenBridgeAndMintPayload, TokenBurnAndBridgePayload } from './types';
3
3
  /**
4
4
  * Tokens API methods
5
5
  */
@@ -58,5 +58,17 @@ export declare const tokensApi: {
58
58
  * @returns Promise with transaction hash response
59
59
  */
60
60
  updateMetadata: (payload: TokenMetadataPayload) => import("../../client/index.js").PromiseWrapper<"custom", Hash, Hash, Hash, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Hash, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Hash>;
61
+ /**
62
+ * Bridge and mint tokens
63
+ * @param payload Token bridge and mint request payload
64
+ * @returns Promise with transaction hash response
65
+ */
66
+ bridgeAndMint: (payload: TokenBridgeAndMintPayload) => import("../../client/index.js").PromiseWrapper<"custom", Hash, Hash, Hash, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Hash, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Hash>;
67
+ /**
68
+ * Burn and bridge tokens
69
+ * @param payload Token burn and bridge request payload
70
+ * @returns Promise with transaction hash response
71
+ */
72
+ burnAndBridge: (payload: TokenBurnAndBridgePayload) => import("../../client/index.js").PromiseWrapper<"custom", Hash, Hash, Hash, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Hash, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Hash>;
61
73
  };
62
74
  export default tokensApi;