@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 +1 -1
- package/dist/src/client/user.d.ts +2 -2
- package/dist/src/client/user.js +6 -2
- package/dist/src/models.d.ts +3 -1
- package/dist/src/models.js +6 -2
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -64,8 +64,8 @@ export declare class UserClient {
|
|
|
64
64
|
*/
|
|
65
65
|
listTabs(settlementStatuses?: string[]): Promise<TabInfo[]>;
|
|
66
66
|
/**
|
|
67
|
-
* Pay
|
|
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.
|
package/dist/src/client/user.js
CHANGED
|
@@ -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,
|
|
108
|
-
: this.client.gateway.payTabErc20(tabId,
|
|
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;
|
package/dist/src/models.d.ts
CHANGED
|
@@ -172,7 +172,9 @@ export declare class TabInfo {
|
|
|
172
172
|
settlementStatus: string;
|
|
173
173
|
createdAt: number;
|
|
174
174
|
updatedAt: number;
|
|
175
|
-
|
|
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 {
|
package/dist/src/models.js
CHANGED
|
@@ -153,7 +153,9 @@ class TabInfo {
|
|
|
153
153
|
settlementStatus;
|
|
154
154
|
createdAt;
|
|
155
155
|
updatedAt;
|
|
156
|
-
|
|
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;
|