@4mica/sdk 1.2.16 → 1.2.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4mica/sdk",
3
- "version": "1.2.15",
3
+ "version": "1.2.16",
4
4
  "description": "TypeScript SDK for interacting with the 4Mica payment network",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -64,8 +64,8 @@ export declare class UserClient {
64
64
  */
65
65
  listTabs(settlementStatuses?: string[]): Promise<TabInfo[]>;
66
66
  /**
67
- * Pay a tab on-chain. Automatically resolves the recipient, asset, and amount
68
- * from the tab and its latest guarantee.
67
+ * Pay the remaining tab balance on-chain. Automatically resolves the recipient,
68
+ * asset, and remaining amount from the tab and its latest guarantee.
69
69
  *
70
70
  * @param tabId - Tab identifier.
71
71
  * @param waitOptions - Optional timeout/polling overrides.
@@ -102,10 +102,14 @@ class UserClient {
102
102
  const guarantee = await this.client.recipient.getLatestGuarantee(tabId);
103
103
  if (!guarantee)
104
104
  throw new Error(`Tab ${tabId} has no guarantee`);
105
+ const remaining = tab.totalAmount > tab.paidAmount ? tab.totalAmount - tab.paidAmount : 0n;
106
+ if (remaining === 0n) {
107
+ throw new Error(`Tab ${tabId} is already fully paid`);
108
+ }
105
109
  const isEth = tab.assetAddress === '0x0000000000000000000000000000000000000000';
106
110
  return isEth
107
- ? this.client.gateway.payTabEth(tabId, guarantee.reqId, guarantee.amount, tab.recipientAddress, opts)
108
- : this.client.gateway.payTabErc20(tabId, guarantee.amount, tab.assetAddress, tab.recipientAddress, opts);
111
+ ? this.client.gateway.payTabEth(tabId, guarantee.reqId, remaining, tab.recipientAddress, opts)
112
+ : this.client.gateway.payTabErc20(tabId, remaining, tab.assetAddress, tab.recipientAddress, opts);
109
113
  }
110
114
  // Explicit overload
111
115
  const reqId = reqIdOrWaitOptions;
@@ -172,7 +172,9 @@ export declare class TabInfo {
172
172
  settlementStatus: string;
173
173
  createdAt: number;
174
174
  updatedAt: number;
175
- constructor(tabId: bigint, userAddress: string, recipientAddress: string, assetAddress: string, startTimestamp: number, ttlSeconds: number, status: string, settlementStatus: string, createdAt: number, updatedAt: number);
175
+ totalAmount: bigint;
176
+ paidAmount: bigint;
177
+ constructor(tabId: bigint, userAddress: string, recipientAddress: string, assetAddress: string, startTimestamp: number, ttlSeconds: number, status: string, settlementStatus: string, createdAt: number, updatedAt: number, totalAmount?: bigint, paidAmount?: bigint);
176
178
  static fromRpc(raw: Record<string, unknown>): TabInfo;
177
179
  }
178
180
  export declare class GuaranteeInfo {
@@ -153,7 +153,9 @@ class TabInfo {
153
153
  settlementStatus;
154
154
  createdAt;
155
155
  updatedAt;
156
- constructor(tabId, userAddress, recipientAddress, assetAddress, startTimestamp, ttlSeconds, status, settlementStatus, createdAt, updatedAt) {
156
+ totalAmount;
157
+ paidAmount;
158
+ constructor(tabId, userAddress, recipientAddress, assetAddress, startTimestamp, ttlSeconds, status, settlementStatus, createdAt, updatedAt, totalAmount = 0n, paidAmount = 0n) {
157
159
  this.tabId = tabId;
158
160
  this.userAddress = userAddress;
159
161
  this.recipientAddress = recipientAddress;
@@ -164,9 +166,11 @@ class TabInfo {
164
166
  this.settlementStatus = settlementStatus;
165
167
  this.createdAt = createdAt;
166
168
  this.updatedAt = updatedAt;
169
+ this.totalAmount = totalAmount;
170
+ this.paidAmount = paidAmount;
167
171
  }
168
172
  static fromRpc(raw) {
169
- return new TabInfo((0, utils_1.parseU256)(((0, serde_1.getAny)(raw, 'tab_id', 'tabId') ?? 0)), ((0, serde_1.getAny)(raw, 'user_address', 'userAddress') ?? ''), ((0, serde_1.getAny)(raw, 'recipient_address', 'recipientAddress') ?? ''), ((0, serde_1.getAny)(raw, 'asset_address', 'assetAddress') ?? ''), Number((0, serde_1.getAny)(raw, 'start_timestamp', 'startTimestamp')), Number((0, serde_1.getAny)(raw, 'ttl_seconds', 'ttlSeconds')), ((0, serde_1.getAny)(raw, 'status') ?? ''), ((0, serde_1.getAny)(raw, 'settlement_status', 'settlementStatus') ?? ''), Number((0, serde_1.getAny)(raw, 'created_at', 'createdAt')), Number((0, serde_1.getAny)(raw, 'updated_at', 'updatedAt')));
173
+ return new TabInfo((0, utils_1.parseU256)(((0, serde_1.getAny)(raw, 'tab_id', 'tabId') ?? 0)), ((0, serde_1.getAny)(raw, 'user_address', 'userAddress') ?? ''), ((0, serde_1.getAny)(raw, 'recipient_address', 'recipientAddress') ?? ''), ((0, serde_1.getAny)(raw, 'asset_address', 'assetAddress') ?? ''), Number((0, serde_1.getAny)(raw, 'start_timestamp', 'startTimestamp')), Number((0, serde_1.getAny)(raw, 'ttl_seconds', 'ttlSeconds')), ((0, serde_1.getAny)(raw, 'status') ?? ''), ((0, serde_1.getAny)(raw, 'settlement_status', 'settlementStatus') ?? ''), Number((0, serde_1.getAny)(raw, 'created_at', 'createdAt')), Number((0, serde_1.getAny)(raw, 'updated_at', 'updatedAt')), (0, utils_1.parseU256)(((0, serde_1.getAny)(raw, 'total_amount', 'totalAmount') ?? 0)), (0, utils_1.parseU256)(((0, serde_1.getAny)(raw, 'paid_amount', 'paidAmount') ?? 0)));
170
174
  }
171
175
  }
172
176
  exports.TabInfo = TabInfo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4mica/sdk",
3
- "version": "1.2.16",
3
+ "version": "1.2.17",
4
4
  "description": "TypeScript SDK for interacting with the 4Mica payment network",
5
5
  "license": "MIT",
6
6
  "repository": {