@otim/sdk-core 0.0.2 → 0.0.4-alpha.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/abi-DW6AS0eM.d.mts +339 -0
- package/dist/abi-DW6AS0eM.d.mts.map +1 -0
- package/dist/abi-OUq-mx1W.d.cts +339 -0
- package/dist/abi-OUq-mx1W.d.cts.map +1 -0
- package/dist/account/index.cjs +1 -1
- package/dist/account/index.d.cts +5 -3
- package/dist/account/index.d.mts +5 -3
- package/dist/account/index.mjs +1 -1
- package/dist/{account-Bwm5PTcc.cjs → account-CRvC_dXT.cjs} +8 -3
- package/dist/account-CRvC_dXT.cjs.map +1 -0
- package/dist/{account-p4sxzIt3.mjs → account-D1NVta26.mjs} +8 -3
- package/dist/account-D1NVta26.mjs.map +1 -0
- package/dist/authorization-6anhDdQX.d.cts +210 -0
- package/dist/authorization-6anhDdQX.d.cts.map +1 -0
- package/dist/authorization-DnNpWjxB.d.mts +210 -0
- package/dist/authorization-DnNpWjxB.d.mts.map +1 -0
- package/dist/clients/index.cjs +3 -2
- package/dist/clients/index.d.cts +3 -3
- package/dist/clients/index.d.mts +3 -3
- package/dist/clients/index.mjs +2 -2
- package/dist/{clients-DBRhkU4y.cjs → clients-BCyzdTLc.cjs} +90 -127
- package/dist/clients-BCyzdTLc.cjs.map +1 -0
- package/dist/{clients-DMKeLhcJ.mjs → clients-Bn4BUElo.mjs} +83 -126
- package/dist/clients-Bn4BUElo.mjs.map +1 -0
- package/dist/config/index.d.cts +2 -2
- package/dist/config/index.d.mts +2 -2
- package/dist/context/index.d.cts +4 -1
- package/dist/context/index.d.mts +4 -1
- package/dist/{index-DW_zBRKz.d.mts → index-BQMXYh9N.d.cts} +2 -13
- package/dist/index-BQMXYh9N.d.cts.map +1 -0
- package/dist/{index-B4fkcFy5.d.mts → index-C5c51xs0.d.mts} +5 -8
- package/dist/index-C5c51xs0.d.mts.map +1 -0
- package/dist/{index-DK-40z4V.d.cts → index-C8H-BPGH.d.cts} +5 -8
- package/dist/index-C8H-BPGH.d.cts.map +1 -0
- package/dist/{index-De8OZ-Be.d.cts → index-Ce_qYSJj.d.cts} +30 -36
- package/dist/index-Ce_qYSJj.d.cts.map +1 -0
- package/dist/{index-e5BLgzcW.d.mts → index-CiyyA-wd.d.mts} +30 -36
- package/dist/index-CiyyA-wd.d.mts.map +1 -0
- package/dist/{index-BnP8vpJJ.d.cts → index-CnjY7cyS.d.mts} +2 -13
- package/dist/index-CnjY7cyS.d.mts.map +1 -0
- package/dist/{index-CcCMIBgF.d.mts → index-DWE1xfOE.d.mts} +4 -1
- package/dist/index-DWE1xfOE.d.mts.map +1 -0
- package/dist/{index-UnaahQgb.d.cts → index-D_7CTJDl.d.mts} +2 -2
- package/dist/{index-C4N2Xixk.d.mts.map → index-D_7CTJDl.d.mts.map} +1 -1
- package/dist/{index-C1HSAemv.d.cts → index-GSspyLr3.d.cts} +4 -1
- package/dist/index-GSspyLr3.d.cts.map +1 -0
- package/dist/{index-C4N2Xixk.d.mts → index-lW-Oor1B.d.cts} +2 -2
- package/dist/{index-UnaahQgb.d.cts.map → index-lW-Oor1B.d.cts.map} +1 -1
- package/dist/index.cjs +5 -4
- package/dist/index.d.cts +9 -8
- package/dist/index.d.mts +9 -8
- package/dist/index.mjs +3 -3
- package/dist/rpc-BDoNl1Sp.d.cts +6885 -0
- package/dist/rpc-BDoNl1Sp.d.cts.map +1 -0
- package/dist/rpc-CygBD_f7.d.mts +6885 -0
- package/dist/rpc-CygBD_f7.d.mts.map +1 -0
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.mts +3 -3
- package/package.json +5 -5
- package/dist/abi-Bd3X6gV9.d.mts +0 -154
- package/dist/abi-Bd3X6gV9.d.mts.map +0 -1
- package/dist/abi-CQuxrNCU.d.cts +0 -154
- package/dist/abi-CQuxrNCU.d.cts.map +0 -1
- package/dist/account-Bwm5PTcc.cjs.map +0 -1
- package/dist/account-p4sxzIt3.mjs.map +0 -1
- package/dist/clients-DBRhkU4y.cjs.map +0 -1
- package/dist/clients-DMKeLhcJ.mjs.map +0 -1
- package/dist/index-B4fkcFy5.d.mts.map +0 -1
- package/dist/index-BnP8vpJJ.d.cts.map +0 -1
- package/dist/index-C1HSAemv.d.cts.map +0 -1
- package/dist/index-CcCMIBgF.d.mts.map +0 -1
- package/dist/index-DK-40z4V.d.cts.map +0 -1
- package/dist/index-DW_zBRKz.d.mts.map +0 -1
- package/dist/index-De8OZ-Be.d.cts.map +0 -1
- package/dist/index-e5BLgzcW.d.mts.map +0 -1
- package/dist/misc-CX4pLJaA.d.mts +0 -42
- package/dist/misc-CX4pLJaA.d.mts.map +0 -1
- package/dist/misc-CpZxSPCP.d.cts +0 -42
- package/dist/misc-CpZxSPCP.d.cts.map +0 -1
|
@@ -9,6 +9,17 @@ let __otim_turnkey_signing = require("@otim/turnkey/signing");
|
|
|
9
9
|
let viem_accounts = require("viem/accounts");
|
|
10
10
|
let __otim_sdk_core_account = require("@otim/sdk-core/account");
|
|
11
11
|
|
|
12
|
+
//#region src/clients/activity.ts
|
|
13
|
+
var ActivityClient = class {
|
|
14
|
+
constructor(apiClient) {
|
|
15
|
+
this.apiClient = apiClient;
|
|
16
|
+
}
|
|
17
|
+
async getInstructionActivity(request) {
|
|
18
|
+
return (await this.apiClient.activity.getInstructionActivity(request)).data;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
12
23
|
//#region src/clients/auth.ts
|
|
13
24
|
var AuthClient = class {
|
|
14
25
|
constructor(apiClient, account, context) {
|
|
@@ -84,46 +95,30 @@ async function createPaymentSigner(params) {
|
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
//#endregion
|
|
87
|
-
//#region src/clients/
|
|
88
|
-
var
|
|
98
|
+
//#region src/clients/orchestration.ts
|
|
99
|
+
var OrchestrationClient = class {
|
|
89
100
|
constructor(apiClient, account, context) {
|
|
90
101
|
this.apiClient = apiClient;
|
|
91
102
|
this.account = account;
|
|
92
103
|
this.context = context;
|
|
93
104
|
}
|
|
94
|
-
async create(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const feeTokenAddress = this.validateAndGetTokenAddress(chainId, token);
|
|
98
|
-
const metadata = this.buildMetadata({
|
|
99
|
-
token,
|
|
100
|
-
amount,
|
|
101
|
-
recipient,
|
|
102
|
-
note,
|
|
103
|
-
dueDate,
|
|
104
|
-
customMetadata
|
|
105
|
-
});
|
|
106
|
-
const payload = this.createPayload({
|
|
107
|
-
chainId,
|
|
108
|
-
recipient,
|
|
109
|
-
amount,
|
|
110
|
-
payer,
|
|
111
|
-
metadata,
|
|
112
|
-
feeTokenAddress
|
|
113
|
-
});
|
|
105
|
+
async create(preparedRequest) {
|
|
106
|
+
(0, __otim_sdk_core_context.assertServerContext)(this.context);
|
|
107
|
+
const { payload, chainId } = preparedRequest;
|
|
114
108
|
const buildResponse = await this.buildAndEnhancePaymentRequest(payload);
|
|
115
|
-
await this.activate(
|
|
116
|
-
buildResponse,
|
|
117
|
-
settlementChainId: chainId
|
|
118
|
-
});
|
|
109
|
+
await this.activate(buildResponse, chainId);
|
|
119
110
|
return {
|
|
120
111
|
requestId: buildResponse.requestId,
|
|
121
112
|
ephemeralWalletAddress: buildResponse.ephemeralWalletAddress
|
|
122
113
|
};
|
|
123
114
|
}
|
|
124
|
-
async
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
async getDetails(request) {
|
|
116
|
+
return this.apiClient.payments.getPaymentRequestDetails(request);
|
|
117
|
+
}
|
|
118
|
+
async list(request) {
|
|
119
|
+
return this.apiClient.payments.getPaymentRequests(request);
|
|
120
|
+
}
|
|
121
|
+
async activate(buildResponse, settlementChainId) {
|
|
127
122
|
const publicClient = this.createPublicClient(settlementChainId);
|
|
128
123
|
const instructions = [...buildResponse.completionInstructions, ...buildResponse.instructions];
|
|
129
124
|
const delegateAddressMap = await this.fetchDelegateAddresses(instructions);
|
|
@@ -140,41 +135,6 @@ var PaymentRequestsClient = class {
|
|
|
140
135
|
instructions: signedInstructions
|
|
141
136
|
});
|
|
142
137
|
}
|
|
143
|
-
validateAndGetTokenAddress(chainId, token) {
|
|
144
|
-
const tokenAddress = (0, __otim_utils_chains.getTokenAddress)(chainId, token);
|
|
145
|
-
if (!tokenAddress) throw new Error(`Token ${token} not supported on chain ${chainId}`);
|
|
146
|
-
if (!(0, __otim_utils_chains.getTokenMetadata)(token)) throw new Error(`Token ${token} metadata not found`);
|
|
147
|
-
return __otim_utils_schemas.hexStringSchema.parse(tokenAddress);
|
|
148
|
-
}
|
|
149
|
-
buildMetadata(params) {
|
|
150
|
-
const { token, amount, recipient, note, dueDate, customMetadata } = params;
|
|
151
|
-
const baseMetadata = (0, __otim_utils_payments.buildPaymentMetadata)({
|
|
152
|
-
tokenSymbol: token,
|
|
153
|
-
amountInUSD: amount,
|
|
154
|
-
fromAccountAddress: recipient,
|
|
155
|
-
note,
|
|
156
|
-
dueDate,
|
|
157
|
-
hasInvoiceMetadata: false
|
|
158
|
-
});
|
|
159
|
-
return customMetadata ? {
|
|
160
|
-
...baseMetadata,
|
|
161
|
-
...customMetadata
|
|
162
|
-
} : baseMetadata;
|
|
163
|
-
}
|
|
164
|
-
createPayload(params) {
|
|
165
|
-
const { chainId, recipient, amount, payer, metadata, feeTokenAddress } = params;
|
|
166
|
-
const chainTokenConfigs = (0, __otim_utils_payments.createChainTokenConfigs)(Object.values(__otim_utils_chains.supportedChains.mainnet).flatMap((chain) => (0, __otim_utils_chains.getChainTokens)(chain.id)));
|
|
167
|
-
return (0, __otim_utils_payments.createComprehensivePaymentRequest)({
|
|
168
|
-
settlementChainId: chainId,
|
|
169
|
-
recipient,
|
|
170
|
-
amount: amount.toString(),
|
|
171
|
-
ephemeralWalletAddress: recipient,
|
|
172
|
-
chainTokenConfigs,
|
|
173
|
-
payerAddress: payer ?? null,
|
|
174
|
-
metadata,
|
|
175
|
-
feeToken: feeTokenAddress
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
138
|
async buildAndEnhancePaymentRequest(payload) {
|
|
179
139
|
const actionNames = (0, __otim_utils_payments.extractActionNamesMap)(payload.completionInstructions, payload.instructions);
|
|
180
140
|
return (0, __otim_utils_payments.addActionNamesToInstructions)((await this.apiClient.payments.buildPaymentRequest(payload)).data, actionNames);
|
|
@@ -195,75 +155,78 @@ var PaymentRequestsClient = class {
|
|
|
195
155
|
}));
|
|
196
156
|
return new Map(addresses);
|
|
197
157
|
}
|
|
198
|
-
async getDetails(request) {
|
|
199
|
-
return this.apiClient.payments.getPaymentRequestDetails(request);
|
|
200
|
-
}
|
|
201
|
-
async listOutgoingPaymentRequests(request) {
|
|
202
|
-
return this.apiClient.payments.getOutgoingPaymentsList(request);
|
|
203
|
-
}
|
|
204
|
-
async listIncomingPaymentRequests(request) {
|
|
205
|
-
return this.apiClient.payments.getIncomingPaymentsList(request);
|
|
206
|
-
}
|
|
207
|
-
async list(request) {
|
|
208
|
-
return this.apiClient.payments.getPaymentRequests(request);
|
|
209
|
-
}
|
|
210
158
|
};
|
|
211
159
|
|
|
212
160
|
//#endregion
|
|
213
|
-
//#region
|
|
214
|
-
function
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
220
|
-
}, _typeof(o);
|
|
161
|
+
//#region src/clients/helpers/prepare-payment-request.ts
|
|
162
|
+
function validateAndGetTokenAddress(chainId, token) {
|
|
163
|
+
const tokenAddress = (0, __otim_utils_chains.getTokenAddress)(chainId, token);
|
|
164
|
+
if (!tokenAddress) throw new Error(`Token ${token} not supported on chain ${chainId}`);
|
|
165
|
+
if (!(0, __otim_utils_chains.getTokenMetadata)(token)) throw new Error(`Token ${token} metadata not found`);
|
|
166
|
+
return __otim_utils_schemas.hexStringSchema.parse(tokenAddress);
|
|
221
167
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
168
|
+
function buildMetadataFromParams(params) {
|
|
169
|
+
const { token, amount, recipient, note, dueDate, customMetadata } = params;
|
|
170
|
+
const baseMetadata = (0, __otim_utils_payments.buildPaymentMetadata)({
|
|
171
|
+
tokenSymbol: token,
|
|
172
|
+
amountInUSD: amount,
|
|
173
|
+
fromAccountAddress: recipient,
|
|
174
|
+
note,
|
|
175
|
+
dueDate,
|
|
176
|
+
hasInvoiceMetadata: false
|
|
177
|
+
});
|
|
178
|
+
return customMetadata ? {
|
|
179
|
+
...baseMetadata,
|
|
180
|
+
...customMetadata
|
|
181
|
+
} : baseMetadata;
|
|
234
182
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
183
|
+
function createPayload(params) {
|
|
184
|
+
const { chainId, recipient, amount, payer, metadata, feeTokenAddress, maxRuns } = params;
|
|
185
|
+
const chainTokenConfigs = (0, __otim_utils_payments.createChainTokenConfigs)(Object.values(__otim_utils_chains.supportedChains.mainnet).flatMap((chain) => (0, __otim_utils_chains.getChainTokens)(chain.id)));
|
|
186
|
+
return (0, __otim_utils_payments.createComprehensivePaymentRequest)({
|
|
187
|
+
settlementChainId: chainId,
|
|
188
|
+
recipient,
|
|
189
|
+
amount: amount.toString(),
|
|
190
|
+
ephemeralWalletAddress: recipient,
|
|
191
|
+
chainTokenConfigs,
|
|
192
|
+
payerAddress: payer ?? null,
|
|
193
|
+
metadata,
|
|
194
|
+
feeToken: feeTokenAddress,
|
|
195
|
+
maxRuns
|
|
196
|
+
});
|
|
241
197
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
198
|
+
function preparePaymentRequest(params) {
|
|
199
|
+
const { chainId, token = "USDC", recipient, amount, payer, note, dueDate, metadata: customMetadata, maxRuns } = params;
|
|
200
|
+
if (dueDate) (0, __otim_utils_helpers.validateIso8601Date)(dueDate);
|
|
201
|
+
const feeTokenAddress = validateAndGetTokenAddress(chainId, token);
|
|
202
|
+
return {
|
|
203
|
+
payload: createPayload({
|
|
204
|
+
chainId,
|
|
205
|
+
recipient,
|
|
206
|
+
amount,
|
|
207
|
+
payer,
|
|
208
|
+
metadata: buildMetadataFromParams({
|
|
209
|
+
token,
|
|
210
|
+
amount,
|
|
211
|
+
recipient,
|
|
212
|
+
note,
|
|
213
|
+
dueDate,
|
|
214
|
+
customMetadata
|
|
215
|
+
}),
|
|
216
|
+
feeTokenAddress,
|
|
217
|
+
maxRuns
|
|
218
|
+
}),
|
|
219
|
+
chainId
|
|
220
|
+
};
|
|
252
221
|
}
|
|
253
222
|
|
|
254
223
|
//#endregion
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
_defineProperty(this, "paymentRequests", void 0);
|
|
262
|
-
this.paymentRequests = new PaymentRequestsClient(apiClient, account, context);
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
//#endregion
|
|
224
|
+
Object.defineProperty(exports, 'ActivityClient', {
|
|
225
|
+
enumerable: true,
|
|
226
|
+
get: function () {
|
|
227
|
+
return ActivityClient;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
267
230
|
Object.defineProperty(exports, 'AuthClient', {
|
|
268
231
|
enumerable: true,
|
|
269
232
|
get: function () {
|
|
@@ -288,10 +251,10 @@ Object.defineProperty(exports, 'OrchestrationClient', {
|
|
|
288
251
|
return OrchestrationClient;
|
|
289
252
|
}
|
|
290
253
|
});
|
|
291
|
-
Object.defineProperty(exports, '
|
|
254
|
+
Object.defineProperty(exports, 'preparePaymentRequest', {
|
|
292
255
|
enumerable: true,
|
|
293
256
|
get: function () {
|
|
294
|
-
return
|
|
257
|
+
return preparePaymentRequest;
|
|
295
258
|
}
|
|
296
259
|
});
|
|
297
|
-
//# sourceMappingURL=clients-
|
|
260
|
+
//# sourceMappingURL=clients-BCyzdTLc.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients-BCyzdTLc.cjs","names":["apiClient: APIClient","apiClient: APIClient","account: OtimAccount","context: OtimClientContext","apiClient: APIClient","apiClient: APIClient","UnifiedPaymentSigner","ApiKeyClientSigningService","ServerWalletSigningService","apiClient: APIClient","account: OtimAccount","context: OtimServerClientContext","hexStringSchema","hexStringSchema","supportedChains"],"sources":["../src/clients/activity.ts","../src/clients/auth.ts","../src/clients/config.ts","../src/clients/delegation.ts","../src/clients/helpers/payment-signer.ts","../src/clients/orchestration.ts","../src/clients/helpers/prepare-payment-request.ts"],"sourcesContent":["import type {\n APIClient,\n GetInstructionActivityRequest,\n GetInstructionActivityResponse,\n} from \"@otim/utils/api\";\n\nexport class ActivityClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getInstructionActivity(\n request: GetInstructionActivityRequest,\n ): Promise<GetInstructionActivityResponse> {\n const response =\n await this.apiClient.activity.getInstructionActivity(request);\n\n return response.data;\n }\n}\n","import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimClientContext } from \"@otim/sdk-core/context\";\nimport type { APIClient, AuthLoginResponse, MeResponse } from \"@otim/utils/api\";\nimport type { Address } from \"viem\";\n\nimport { parseSignatureToVRS } from \"@otim/utils/helpers\";\n\nimport { createLoginSiweMessage } from \"@otim/sdk-core/config\";\nimport { assertRequiresAuth } from \"@otim/sdk-core/context\";\n\nexport interface LoginOptions {\n address: Address;\n}\n\nexport class AuthClient {\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimClientContext,\n ) {}\n\n async login({ address }: LoginOptions): Promise<AuthLoginResponse> {\n assertRequiresAuth(this.context);\n\n const message = createLoginSiweMessage(address, Date.now().toString());\n const signature = await this.account.signMessage({ message });\n const vrsParsedSignature = parseSignatureToVRS(signature);\n\n const response = await this.apiClient.auth.login({\n siwe: message,\n signature: vrsParsedSignature,\n });\n\n return response.data;\n }\n\n async getCurrentUser(): Promise<MeResponse> {\n const response = await this.apiClient.auth.me();\n return response.data;\n }\n}\n","import type {\n APIClient,\n GetMaxPriorityFeePerGasEstimateRequest,\n GetMaxPriorityFeePerGasEstimateResponse,\n} from \"@otim/utils/api\";\n\nexport class ConfigClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getMaxPriorityFeeEstimate({\n chainId,\n }: GetMaxPriorityFeePerGasEstimateRequest): Promise<GetMaxPriorityFeePerGasEstimateResponse> {\n const response =\n await this.apiClient.config.getMaxPriorityFeePerGasEstimate({ chainId });\n\n return response.data;\n }\n}\n","import type {\n APIClient,\n DelegationCreateRequest,\n DelegationStatusRequest,\n DelegationStatusResponse,\n GetDelegateAddressRequest,\n GetDelegateAddressResponse,\n} from \"@otim/utils/api\";\n\nexport class DelegationClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getDelegateAddress({\n chainId,\n }: GetDelegateAddressRequest): Promise<GetDelegateAddressResponse> {\n const response = await this.apiClient.config.getDelegateAddress({\n chainId,\n });\n\n return response.data;\n }\n\n async getDelegationStatus(\n options: DelegationStatusRequest,\n ): Promise<DelegationStatusResponse> {\n const response = await this.apiClient.account.getDelegationStatus({\n address: options.address,\n chainId: options.chainId,\n });\n\n return response.data;\n }\n\n async createDelegation(\n delegationRequest: DelegationCreateRequest,\n ): Promise<void> {\n await this.apiClient.account.createDelegation(delegationRequest);\n }\n}\n","import type { OtimServerClientContext } from \"@otim/sdk-core/context\";\nimport type { PaymentResponseWithActionNames } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\nimport type { PublicClient } from \"viem\";\n\nimport {\n ApiKeyClientSigningService,\n ServerWalletSigningService,\n UnifiedPaymentSigner,\n} from \"@otim/turnkey/signing\";\nimport { createWalletClient, http } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\n\nimport { isApiAccountConfig } from \"@otim/sdk-core/account\";\n\nexport interface CreatePaymentSignerParams {\n context: OtimServerClientContext;\n buildResponse: PaymentResponseWithActionNames;\n publicClient: PublicClient;\n delegateAddressMap: Map<number, Address>;\n}\n\ntype CreatePaymentSignerResult = Awaited<\n ReturnType<UnifiedPaymentSigner[\"signAll\"]>\n>;\n\nexport async function createPaymentSigner(\n params: CreatePaymentSignerParams,\n): Promise<CreatePaymentSignerResult> {\n const { context, buildResponse, publicClient, delegateAddressMap } = params;\n\n if (isApiAccountConfig(context.config)) {\n const signingService = new ApiKeyClientSigningService(\n context.config.publicKey,\n context.config.privateKey,\n );\n\n const signer = new UnifiedPaymentSigner({\n buildResponse,\n signingService,\n publicClient,\n delegateAddressMap,\n });\n\n return signer.signAll();\n }\n\n const account = privateKeyToAccount(context.config.privateKey);\n const walletClient = createWalletClient({\n account,\n transport: http(),\n });\n\n const signingService =\n ServerWalletSigningService.fromViemWallet(walletClient);\n\n const signer = new UnifiedPaymentSigner({\n buildResponse,\n signingService,\n publicClient,\n delegateAddressMap,\n });\n\n return signer.signAll();\n}\n","import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimServerClientContext } from \"@otim/sdk-core/context\";\nimport type {\n APIClient,\n GetPaymentRequestsRequest,\n GetPaymentRequestsResponse,\n PaginatedServiceResponse,\n PaymentRequestBuildRequest,\n PaymentRequestDetailsRequest,\n PaymentRequestDetailsResponse,\n ServiceResponse,\n} from \"@otim/utils/api\";\nimport type { PaymentResponseWithActionNames } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\nimport type { PublicClient } from \"viem\";\n\nimport { getChainById } from \"@otim/utils/chains\";\nimport {\n addActionNamesToInstructions,\n extractActionNamesMap,\n} from \"@otim/utils/payments\";\nimport { hexStringSchema } from \"@otim/utils/schemas\";\nimport { createPublicClient, http } from \"viem\";\n\nimport { assertServerContext } from \"@otim/sdk-core/context\";\n\nimport { createPaymentSigner } from \"./helpers/payment-signer\";\nimport type { PreparedPaymentRequest } from \"./helpers/prepare-payment-request\";\n\nexport type { PreparedPaymentRequest } from \"./helpers/prepare-payment-request\";\n\nexport interface CreatePaymentRequestResponse {\n requestId: string;\n ephemeralWalletAddress: Address;\n}\n\ntype PaymentInstruction =\n PaymentResponseWithActionNames[\"completionInstructions\"][number];\n\nexport class OrchestrationClient {\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimServerClientContext,\n ) {}\n\n async create(\n preparedRequest: PreparedPaymentRequest,\n ): Promise<CreatePaymentRequestResponse> {\n assertServerContext(this.context);\n\n const { payload, chainId } = preparedRequest;\n\n const buildResponse = await this.buildAndEnhancePaymentRequest(payload);\n await this.activate(buildResponse, chainId);\n\n return {\n requestId: buildResponse.requestId,\n ephemeralWalletAddress: buildResponse.ephemeralWalletAddress,\n };\n }\n\n async getDetails(\n request: PaymentRequestDetailsRequest,\n ): Promise<ServiceResponse<PaymentRequestDetailsResponse>> {\n return this.apiClient.payments.getPaymentRequestDetails(request);\n }\n\n async list(\n request: GetPaymentRequestsRequest,\n ): Promise<PaginatedServiceResponse<GetPaymentRequestsResponse>> {\n return this.apiClient.payments.getPaymentRequests(request);\n }\n\n private async activate(\n buildResponse: PaymentResponseWithActionNames,\n settlementChainId: number,\n ): Promise<void> {\n const publicClient = this.createPublicClient(settlementChainId);\n\n const instructions = [\n ...buildResponse.completionInstructions,\n ...buildResponse.instructions,\n ];\n\n const delegateAddressMap = await this.fetchDelegateAddresses(instructions);\n\n const {\n signedAuthorization,\n completionInstructions,\n instructions: signedInstructions,\n } = await createPaymentSigner({\n context: this.context,\n buildResponse,\n publicClient,\n delegateAddressMap,\n });\n\n await this.apiClient.payments.newPaymentRequest({\n requestId: buildResponse.requestId,\n signedAuthorization,\n completionInstructions,\n instructions: signedInstructions,\n });\n }\n\n private async buildAndEnhancePaymentRequest(\n payload: PaymentRequestBuildRequest,\n ): Promise<PaymentResponseWithActionNames> {\n const actionNames = extractActionNamesMap(\n payload.completionInstructions,\n payload.instructions,\n );\n\n const response = await this.apiClient.payments.buildPaymentRequest(payload);\n\n return addActionNamesToInstructions(response.data, actionNames);\n }\n\n private createPublicClient(chainId: number): PublicClient {\n const chain = getChainById(chainId);\n if (!chain) {\n throw new Error(`Chain with id ${chainId} not found`);\n }\n\n return createPublicClient({ chain, transport: http() });\n }\n\n private async fetchDelegateAddresses(\n instructions: PaymentInstruction[],\n ): Promise<Map<number, Address>> {\n const chainIds = Array.from(\n new Set(instructions.map((instruction) => instruction.chainId)),\n );\n\n const addresses = await Promise.all(\n chainIds.map(async (chainId) => {\n const response = await this.apiClient.config.getDelegateAddress({\n chainId,\n });\n const address = hexStringSchema.parse(\n response.data.otimDelegateAddress,\n );\n return [chainId, address] as const;\n }),\n );\n\n return new Map(addresses);\n }\n}\n","import type { PaymentRequestBuildRequest } from \"@otim/utils/api\";\nimport type { SupportedChainId } from \"@otim/utils/chains\";\nimport type { Nullable } from \"@otim/utils/helpers\";\nimport type { PaymentRequestMetadata } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\n\nimport {\n getChainTokens,\n getTokenAddress,\n getTokenMetadata,\n supportedChains,\n} from \"@otim/utils/chains\";\nimport { validateIso8601Date } from \"@otim/utils/helpers\";\nimport {\n buildPaymentMetadata,\n createChainTokenConfigs,\n createComprehensivePaymentRequest,\n} from \"@otim/utils/payments\";\nimport { hexStringSchema } from \"@otim/utils/schemas\";\n\nexport interface PreparePaymentRequestParams {\n amount: number;\n chainId: SupportedChainId;\n recipient: Address;\n token?: \"USDC\" | \"USDT\";\n payer?: Nullable<Address>;\n dueDate?: string;\n metadata?: PaymentRequestMetadata;\n note?: string;\n maxRuns?: number;\n}\n\nexport interface PreparedPaymentRequest {\n payload: PaymentRequestBuildRequest;\n chainId: number;\n}\n\nfunction validateAndGetTokenAddress(chainId: number, token: string): Address {\n const tokenAddress = getTokenAddress(chainId, token);\n if (!tokenAddress) {\n throw new Error(`Token ${token} not supported on chain ${chainId}`);\n }\n\n const tokenMetadata = getTokenMetadata(token);\n if (!tokenMetadata) {\n throw new Error(`Token ${token} metadata not found`);\n }\n\n return hexStringSchema.parse(tokenAddress);\n}\n\nfunction buildMetadataFromParams(params: {\n token: string;\n amount: number;\n recipient: Address;\n note?: string;\n dueDate?: string;\n customMetadata?: PaymentRequestMetadata;\n}): PaymentRequestMetadata {\n const { token, amount, recipient, note, dueDate, customMetadata } = params;\n\n const baseMetadata = buildPaymentMetadata({\n tokenSymbol: token,\n amountInUSD: amount,\n fromAccountAddress: recipient,\n note,\n dueDate,\n hasInvoiceMetadata: false,\n });\n\n return customMetadata ? { ...baseMetadata, ...customMetadata } : baseMetadata;\n}\n\nfunction createPayload(params: {\n chainId: number;\n recipient: Address;\n amount: number;\n payer?: Address | null;\n metadata: PaymentRequestMetadata;\n feeTokenAddress: Address;\n maxRuns?: number;\n}): PaymentRequestBuildRequest {\n const {\n chainId,\n recipient,\n amount,\n payer,\n metadata,\n feeTokenAddress,\n maxRuns,\n } = params;\n\n const tokens = Object.values(supportedChains.mainnet).flatMap((chain) =>\n getChainTokens(chain.id),\n );\n\n const chainTokenConfigs = createChainTokenConfigs(tokens);\n\n return createComprehensivePaymentRequest({\n settlementChainId: chainId,\n recipient,\n amount: amount.toString(),\n ephemeralWalletAddress: recipient,\n chainTokenConfigs,\n payerAddress: payer ?? null,\n metadata,\n feeToken: feeTokenAddress,\n maxRuns,\n });\n}\n\nexport function preparePaymentRequest(\n params: PreparePaymentRequestParams,\n): PreparedPaymentRequest {\n const {\n chainId,\n token = \"USDC\",\n recipient,\n amount,\n payer,\n note,\n dueDate,\n metadata: customMetadata,\n maxRuns,\n } = params;\n\n if (dueDate) {\n validateIso8601Date(dueDate);\n }\n\n const feeTokenAddress = validateAndGetTokenAddress(chainId, token);\n const metadata = buildMetadataFromParams({\n token,\n amount,\n recipient,\n note,\n dueDate,\n customMetadata,\n });\n\n const payload = createPayload({\n chainId,\n recipient,\n amount,\n payer,\n metadata,\n feeTokenAddress,\n maxRuns,\n });\n\n return { payload, chainId };\n}\n"],"mappings":";;;;;;;;;;;;AAMA,IAAa,iBAAb,MAA4B;CAC1B,YAAY,AAAiBA,WAAsB;EAAtB;;CAE7B,MAAM,uBACJ,SACyC;AAIzC,UAFE,MAAM,KAAK,UAAU,SAAS,uBAAuB,QAAQ,EAE/C;;;;;;ACDpB,IAAa,aAAb,MAAwB;CACtB,YACE,AAAiBC,WACjB,AAAiBC,SACjB,AAAiBC,SACjB;EAHiB;EACA;EACA;;CAGnB,MAAM,MAAM,EAAE,WAAqD;AACjE,kDAAmB,KAAK,QAAQ;EAEhC,MAAM,6DAAiC,SAAS,KAAK,KAAK,CAAC,UAAU,CAAC;EAEtE,MAAM,mEADY,MAAM,KAAK,QAAQ,YAAY,EAAE,SAAS,CAAC,CACJ;AAOzD,UALiB,MAAM,KAAK,UAAU,KAAK,MAAM;GAC/C,MAAM;GACN,WAAW;GACZ,CAAC,EAEc;;CAGlB,MAAM,iBAAsC;AAE1C,UADiB,MAAM,KAAK,UAAU,KAAK,IAAI,EAC/B;;;;;;AChCpB,IAAa,eAAb,MAA0B;CACxB,YAAY,AAAiBC,WAAsB;EAAtB;;CAE7B,MAAM,0BAA0B,EAC9B,WAC2F;AAI3F,UAFE,MAAM,KAAK,UAAU,OAAO,gCAAgC,EAAE,SAAS,CAAC,EAE1D;;;;;;ACNpB,IAAa,mBAAb,MAA8B;CAC5B,YAAY,AAAiBC,WAAsB;EAAtB;;CAE7B,MAAM,mBAAmB,EACvB,WACiE;AAKjE,UAJiB,MAAM,KAAK,UAAU,OAAO,mBAAmB,EAC9D,SACD,CAAC,EAEc;;CAGlB,MAAM,oBACJ,SACmC;AAMnC,UALiB,MAAM,KAAK,UAAU,QAAQ,oBAAoB;GAChE,SAAS,QAAQ;GACjB,SAAS,QAAQ;GAClB,CAAC,EAEc;;CAGl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EAAE,GAAG;EAAc,GAAG;EAAgB,GAAG;;AAGnE,SAAS,cAAc,QAQQ;CAC7B,MAAM,EACJ,SACA,WACA,QACA,OACA,UACA,iBACA,YACE;CAMJ,MAAM,uEAJS,OAAO,OAAOC,oCAAgB,QAAQ,CAAC,SAAS,kDAC9C,MAAM,GAAG,CACzB,CAEwD;AAEzD,qEAAyC;EACvC,mBAAmB;EACnB;EACA,QAAQ,OAAO,UAAU;EACzB,wBAAwB;EACxB;EACA,cAAc,SAAS;EACvB;EACA,UAAU;EACV;EACD,CAAC;;AAGJ,SAAgB,sBACd,QACwB;CACxB,MAAM,EACJ,SACA,QAAQ,QACR,WACA,QACA,OACA,MACA,SACA,UAAU,gBACV,YACE;AAEJ,KAAI,QACF,+CAAoB,QAAQ;CAG9B,MAAM,kBAAkB,2BAA2B,SAAS,MAAM;AAoBlE,QAAO;EAAE,SAVO,cAAc;GAC5B;GACA;GACA;GACA;GACA,UAde,wBAAwB;IACvC;IACA;IACA;IACA;IACA;IACA;IACD,CAAC;GAQA;GACA;GACD,CAAC;EAEgB;EAAS"}
|
|
@@ -9,6 +9,17 @@ import { ApiKeyClientSigningService, ServerWalletSigningService, UnifiedPaymentS
|
|
|
9
9
|
import { privateKeyToAccount } from "viem/accounts";
|
|
10
10
|
import { isApiAccountConfig } from "@otim/sdk-core/account";
|
|
11
11
|
|
|
12
|
+
//#region src/clients/activity.ts
|
|
13
|
+
var ActivityClient = class {
|
|
14
|
+
constructor(apiClient) {
|
|
15
|
+
this.apiClient = apiClient;
|
|
16
|
+
}
|
|
17
|
+
async getInstructionActivity(request) {
|
|
18
|
+
return (await this.apiClient.activity.getInstructionActivity(request)).data;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
12
23
|
//#region src/clients/auth.ts
|
|
13
24
|
var AuthClient = class {
|
|
14
25
|
constructor(apiClient, account, context) {
|
|
@@ -84,46 +95,30 @@ async function createPaymentSigner(params) {
|
|
|
84
95
|
}
|
|
85
96
|
|
|
86
97
|
//#endregion
|
|
87
|
-
//#region src/clients/
|
|
88
|
-
var
|
|
98
|
+
//#region src/clients/orchestration.ts
|
|
99
|
+
var OrchestrationClient = class {
|
|
89
100
|
constructor(apiClient, account, context) {
|
|
90
101
|
this.apiClient = apiClient;
|
|
91
102
|
this.account = account;
|
|
92
103
|
this.context = context;
|
|
93
104
|
}
|
|
94
|
-
async create(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const feeTokenAddress = this.validateAndGetTokenAddress(chainId, token);
|
|
98
|
-
const metadata = this.buildMetadata({
|
|
99
|
-
token,
|
|
100
|
-
amount,
|
|
101
|
-
recipient,
|
|
102
|
-
note,
|
|
103
|
-
dueDate,
|
|
104
|
-
customMetadata
|
|
105
|
-
});
|
|
106
|
-
const payload = this.createPayload({
|
|
107
|
-
chainId,
|
|
108
|
-
recipient,
|
|
109
|
-
amount,
|
|
110
|
-
payer,
|
|
111
|
-
metadata,
|
|
112
|
-
feeTokenAddress
|
|
113
|
-
});
|
|
105
|
+
async create(preparedRequest) {
|
|
106
|
+
assertServerContext(this.context);
|
|
107
|
+
const { payload, chainId } = preparedRequest;
|
|
114
108
|
const buildResponse = await this.buildAndEnhancePaymentRequest(payload);
|
|
115
|
-
await this.activate(
|
|
116
|
-
buildResponse,
|
|
117
|
-
settlementChainId: chainId
|
|
118
|
-
});
|
|
109
|
+
await this.activate(buildResponse, chainId);
|
|
119
110
|
return {
|
|
120
111
|
requestId: buildResponse.requestId,
|
|
121
112
|
ephemeralWalletAddress: buildResponse.ephemeralWalletAddress
|
|
122
113
|
};
|
|
123
114
|
}
|
|
124
|
-
async
|
|
125
|
-
|
|
126
|
-
|
|
115
|
+
async getDetails(request) {
|
|
116
|
+
return this.apiClient.payments.getPaymentRequestDetails(request);
|
|
117
|
+
}
|
|
118
|
+
async list(request) {
|
|
119
|
+
return this.apiClient.payments.getPaymentRequests(request);
|
|
120
|
+
}
|
|
121
|
+
async activate(buildResponse, settlementChainId) {
|
|
127
122
|
const publicClient = this.createPublicClient(settlementChainId);
|
|
128
123
|
const instructions = [...buildResponse.completionInstructions, ...buildResponse.instructions];
|
|
129
124
|
const delegateAddressMap = await this.fetchDelegateAddresses(instructions);
|
|
@@ -140,41 +135,6 @@ var PaymentRequestsClient = class {
|
|
|
140
135
|
instructions: signedInstructions
|
|
141
136
|
});
|
|
142
137
|
}
|
|
143
|
-
validateAndGetTokenAddress(chainId, token) {
|
|
144
|
-
const tokenAddress = getTokenAddress(chainId, token);
|
|
145
|
-
if (!tokenAddress) throw new Error(`Token ${token} not supported on chain ${chainId}`);
|
|
146
|
-
if (!getTokenMetadata(token)) throw new Error(`Token ${token} metadata not found`);
|
|
147
|
-
return hexStringSchema.parse(tokenAddress);
|
|
148
|
-
}
|
|
149
|
-
buildMetadata(params) {
|
|
150
|
-
const { token, amount, recipient, note, dueDate, customMetadata } = params;
|
|
151
|
-
const baseMetadata = buildPaymentMetadata({
|
|
152
|
-
tokenSymbol: token,
|
|
153
|
-
amountInUSD: amount,
|
|
154
|
-
fromAccountAddress: recipient,
|
|
155
|
-
note,
|
|
156
|
-
dueDate,
|
|
157
|
-
hasInvoiceMetadata: false
|
|
158
|
-
});
|
|
159
|
-
return customMetadata ? {
|
|
160
|
-
...baseMetadata,
|
|
161
|
-
...customMetadata
|
|
162
|
-
} : baseMetadata;
|
|
163
|
-
}
|
|
164
|
-
createPayload(params) {
|
|
165
|
-
const { chainId, recipient, amount, payer, metadata, feeTokenAddress } = params;
|
|
166
|
-
const chainTokenConfigs = createChainTokenConfigs(Object.values(supportedChains.mainnet).flatMap((chain) => getChainTokens(chain.id)));
|
|
167
|
-
return createComprehensivePaymentRequest({
|
|
168
|
-
settlementChainId: chainId,
|
|
169
|
-
recipient,
|
|
170
|
-
amount: amount.toString(),
|
|
171
|
-
ephemeralWalletAddress: recipient,
|
|
172
|
-
chainTokenConfigs,
|
|
173
|
-
payerAddress: payer ?? null,
|
|
174
|
-
metadata,
|
|
175
|
-
feeToken: feeTokenAddress
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
138
|
async buildAndEnhancePaymentRequest(payload) {
|
|
179
139
|
const actionNames = extractActionNamesMap(payload.completionInstructions, payload.instructions);
|
|
180
140
|
return addActionNamesToInstructions((await this.apiClient.payments.buildPaymentRequest(payload)).data, actionNames);
|
|
@@ -195,74 +155,71 @@ var PaymentRequestsClient = class {
|
|
|
195
155
|
}));
|
|
196
156
|
return new Map(addresses);
|
|
197
157
|
}
|
|
198
|
-
async getDetails(request) {
|
|
199
|
-
return this.apiClient.payments.getPaymentRequestDetails(request);
|
|
200
|
-
}
|
|
201
|
-
async listOutgoingPaymentRequests(request) {
|
|
202
|
-
return this.apiClient.payments.getOutgoingPaymentsList(request);
|
|
203
|
-
}
|
|
204
|
-
async listIncomingPaymentRequests(request) {
|
|
205
|
-
return this.apiClient.payments.getIncomingPaymentsList(request);
|
|
206
|
-
}
|
|
207
|
-
async list(request) {
|
|
208
|
-
return this.apiClient.payments.getPaymentRequests(request);
|
|
209
|
-
}
|
|
210
158
|
};
|
|
211
159
|
|
|
212
160
|
//#endregion
|
|
213
|
-
//#region
|
|
214
|
-
function
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
220
|
-
}, _typeof(o);
|
|
161
|
+
//#region src/clients/helpers/prepare-payment-request.ts
|
|
162
|
+
function validateAndGetTokenAddress(chainId, token) {
|
|
163
|
+
const tokenAddress = getTokenAddress(chainId, token);
|
|
164
|
+
if (!tokenAddress) throw new Error(`Token ${token} not supported on chain ${chainId}`);
|
|
165
|
+
if (!getTokenMetadata(token)) throw new Error(`Token ${token} metadata not found`);
|
|
166
|
+
return hexStringSchema.parse(tokenAddress);
|
|
221
167
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
168
|
+
function buildMetadataFromParams(params) {
|
|
169
|
+
const { token, amount, recipient, note, dueDate, customMetadata } = params;
|
|
170
|
+
const baseMetadata = buildPaymentMetadata({
|
|
171
|
+
tokenSymbol: token,
|
|
172
|
+
amountInUSD: amount,
|
|
173
|
+
fromAccountAddress: recipient,
|
|
174
|
+
note,
|
|
175
|
+
dueDate,
|
|
176
|
+
hasInvoiceMetadata: false
|
|
177
|
+
});
|
|
178
|
+
return customMetadata ? {
|
|
179
|
+
...baseMetadata,
|
|
180
|
+
...customMetadata
|
|
181
|
+
} : baseMetadata;
|
|
234
182
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
183
|
+
function createPayload(params) {
|
|
184
|
+
const { chainId, recipient, amount, payer, metadata, feeTokenAddress, maxRuns } = params;
|
|
185
|
+
const chainTokenConfigs = createChainTokenConfigs(Object.values(supportedChains.mainnet).flatMap((chain) => getChainTokens(chain.id)));
|
|
186
|
+
return createComprehensivePaymentRequest({
|
|
187
|
+
settlementChainId: chainId,
|
|
188
|
+
recipient,
|
|
189
|
+
amount: amount.toString(),
|
|
190
|
+
ephemeralWalletAddress: recipient,
|
|
191
|
+
chainTokenConfigs,
|
|
192
|
+
payerAddress: payer ?? null,
|
|
193
|
+
metadata,
|
|
194
|
+
feeToken: feeTokenAddress,
|
|
195
|
+
maxRuns
|
|
196
|
+
});
|
|
241
197
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
198
|
+
function preparePaymentRequest(params) {
|
|
199
|
+
const { chainId, token = "USDC", recipient, amount, payer, note, dueDate, metadata: customMetadata, maxRuns } = params;
|
|
200
|
+
if (dueDate) validateIso8601Date(dueDate);
|
|
201
|
+
const feeTokenAddress = validateAndGetTokenAddress(chainId, token);
|
|
202
|
+
return {
|
|
203
|
+
payload: createPayload({
|
|
204
|
+
chainId,
|
|
205
|
+
recipient,
|
|
206
|
+
amount,
|
|
207
|
+
payer,
|
|
208
|
+
metadata: buildMetadataFromParams({
|
|
209
|
+
token,
|
|
210
|
+
amount,
|
|
211
|
+
recipient,
|
|
212
|
+
note,
|
|
213
|
+
dueDate,
|
|
214
|
+
customMetadata
|
|
215
|
+
}),
|
|
216
|
+
feeTokenAddress,
|
|
217
|
+
maxRuns
|
|
218
|
+
}),
|
|
219
|
+
chainId
|
|
220
|
+
};
|
|
252
221
|
}
|
|
253
222
|
|
|
254
223
|
//#endregion
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
constructor(apiClient, account, context) {
|
|
258
|
-
this.apiClient = apiClient;
|
|
259
|
-
this.account = account;
|
|
260
|
-
this.context = context;
|
|
261
|
-
_defineProperty(this, "paymentRequests", void 0);
|
|
262
|
-
this.paymentRequests = new PaymentRequestsClient(apiClient, account, context);
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
//#endregion
|
|
267
|
-
export { AuthClient as a, ConfigClient as i, PaymentRequestsClient as n, DelegationClient as r, OrchestrationClient as t };
|
|
268
|
-
//# sourceMappingURL=clients-DMKeLhcJ.mjs.map
|
|
224
|
+
export { AuthClient as a, ConfigClient as i, OrchestrationClient as n, ActivityClient as o, DelegationClient as r, preparePaymentRequest as t };
|
|
225
|
+
//# sourceMappingURL=clients-Bn4BUElo.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients-Bn4BUElo.mjs","names":["apiClient: APIClient","apiClient: APIClient","account: OtimAccount","context: OtimClientContext","apiClient: APIClient","apiClient: APIClient","apiClient: APIClient","account: OtimAccount","context: OtimServerClientContext"],"sources":["../src/clients/activity.ts","../src/clients/auth.ts","../src/clients/config.ts","../src/clients/delegation.ts","../src/clients/helpers/payment-signer.ts","../src/clients/orchestration.ts","../src/clients/helpers/prepare-payment-request.ts"],"sourcesContent":["import type {\n APIClient,\n GetInstructionActivityRequest,\n GetInstructionActivityResponse,\n} from \"@otim/utils/api\";\n\nexport class ActivityClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getInstructionActivity(\n request: GetInstructionActivityRequest,\n ): Promise<GetInstructionActivityResponse> {\n const response =\n await this.apiClient.activity.getInstructionActivity(request);\n\n return response.data;\n }\n}\n","import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimClientContext } from \"@otim/sdk-core/context\";\nimport type { APIClient, AuthLoginResponse, MeResponse } from \"@otim/utils/api\";\nimport type { Address } from \"viem\";\n\nimport { parseSignatureToVRS } from \"@otim/utils/helpers\";\n\nimport { createLoginSiweMessage } from \"@otim/sdk-core/config\";\nimport { assertRequiresAuth } from \"@otim/sdk-core/context\";\n\nexport interface LoginOptions {\n address: Address;\n}\n\nexport class AuthClient {\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimClientContext,\n ) {}\n\n async login({ address }: LoginOptions): Promise<AuthLoginResponse> {\n assertRequiresAuth(this.context);\n\n const message = createLoginSiweMessage(address, Date.now().toString());\n const signature = await this.account.signMessage({ message });\n const vrsParsedSignature = parseSignatureToVRS(signature);\n\n const response = await this.apiClient.auth.login({\n siwe: message,\n signature: vrsParsedSignature,\n });\n\n return response.data;\n }\n\n async getCurrentUser(): Promise<MeResponse> {\n const response = await this.apiClient.auth.me();\n return response.data;\n }\n}\n","import type {\n APIClient,\n GetMaxPriorityFeePerGasEstimateRequest,\n GetMaxPriorityFeePerGasEstimateResponse,\n} from \"@otim/utils/api\";\n\nexport class ConfigClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getMaxPriorityFeeEstimate({\n chainId,\n }: GetMaxPriorityFeePerGasEstimateRequest): Promise<GetMaxPriorityFeePerGasEstimateResponse> {\n const response =\n await this.apiClient.config.getMaxPriorityFeePerGasEstimate({ chainId });\n\n return response.data;\n }\n}\n","import type {\n APIClient,\n DelegationCreateRequest,\n DelegationStatusRequest,\n DelegationStatusResponse,\n GetDelegateAddressRequest,\n GetDelegateAddressResponse,\n} from \"@otim/utils/api\";\n\nexport class DelegationClient {\n constructor(private readonly apiClient: APIClient) {}\n\n async getDelegateAddress({\n chainId,\n }: GetDelegateAddressRequest): Promise<GetDelegateAddressResponse> {\n const response = await this.apiClient.config.getDelegateAddress({\n chainId,\n });\n\n return response.data;\n }\n\n async getDelegationStatus(\n options: DelegationStatusRequest,\n ): Promise<DelegationStatusResponse> {\n const response = await this.apiClient.account.getDelegationStatus({\n address: options.address,\n chainId: options.chainId,\n });\n\n return response.data;\n }\n\n async createDelegation(\n delegationRequest: DelegationCreateRequest,\n ): Promise<void> {\n await this.apiClient.account.createDelegation(delegationRequest);\n }\n}\n","import type { OtimServerClientContext } from \"@otim/sdk-core/context\";\nimport type { PaymentResponseWithActionNames } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\nimport type { PublicClient } from \"viem\";\n\nimport {\n ApiKeyClientSigningService,\n ServerWalletSigningService,\n UnifiedPaymentSigner,\n} from \"@otim/turnkey/signing\";\nimport { createWalletClient, http } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\n\nimport { isApiAccountConfig } from \"@otim/sdk-core/account\";\n\nexport interface CreatePaymentSignerParams {\n context: OtimServerClientContext;\n buildResponse: PaymentResponseWithActionNames;\n publicClient: PublicClient;\n delegateAddressMap: Map<number, Address>;\n}\n\ntype CreatePaymentSignerResult = Awaited<\n ReturnType<UnifiedPaymentSigner[\"signAll\"]>\n>;\n\nexport async function createPaymentSigner(\n params: CreatePaymentSignerParams,\n): Promise<CreatePaymentSignerResult> {\n const { context, buildResponse, publicClient, delegateAddressMap } = params;\n\n if (isApiAccountConfig(context.config)) {\n const signingService = new ApiKeyClientSigningService(\n context.config.publicKey,\n context.config.privateKey,\n );\n\n const signer = new UnifiedPaymentSigner({\n buildResponse,\n signingService,\n publicClient,\n delegateAddressMap,\n });\n\n return signer.signAll();\n }\n\n const account = privateKeyToAccount(context.config.privateKey);\n const walletClient = createWalletClient({\n account,\n transport: http(),\n });\n\n const signingService =\n ServerWalletSigningService.fromViemWallet(walletClient);\n\n const signer = new UnifiedPaymentSigner({\n buildResponse,\n signingService,\n publicClient,\n delegateAddressMap,\n });\n\n return signer.signAll();\n}\n","import type { OtimAccount } from \"@otim/sdk-core/account\";\nimport type { OtimServerClientContext } from \"@otim/sdk-core/context\";\nimport type {\n APIClient,\n GetPaymentRequestsRequest,\n GetPaymentRequestsResponse,\n PaginatedServiceResponse,\n PaymentRequestBuildRequest,\n PaymentRequestDetailsRequest,\n PaymentRequestDetailsResponse,\n ServiceResponse,\n} from \"@otim/utils/api\";\nimport type { PaymentResponseWithActionNames } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\nimport type { PublicClient } from \"viem\";\n\nimport { getChainById } from \"@otim/utils/chains\";\nimport {\n addActionNamesToInstructions,\n extractActionNamesMap,\n} from \"@otim/utils/payments\";\nimport { hexStringSchema } from \"@otim/utils/schemas\";\nimport { createPublicClient, http } from \"viem\";\n\nimport { assertServerContext } from \"@otim/sdk-core/context\";\n\nimport { createPaymentSigner } from \"./helpers/payment-signer\";\nimport type { PreparedPaymentRequest } from \"./helpers/prepare-payment-request\";\n\nexport type { PreparedPaymentRequest } from \"./helpers/prepare-payment-request\";\n\nexport interface CreatePaymentRequestResponse {\n requestId: string;\n ephemeralWalletAddress: Address;\n}\n\ntype PaymentInstruction =\n PaymentResponseWithActionNames[\"completionInstructions\"][number];\n\nexport class OrchestrationClient {\n constructor(\n private readonly apiClient: APIClient,\n private readonly account: OtimAccount,\n private readonly context: OtimServerClientContext,\n ) {}\n\n async create(\n preparedRequest: PreparedPaymentRequest,\n ): Promise<CreatePaymentRequestResponse> {\n assertServerContext(this.context);\n\n const { payload, chainId } = preparedRequest;\n\n const buildResponse = await this.buildAndEnhancePaymentRequest(payload);\n await this.activate(buildResponse, chainId);\n\n return {\n requestId: buildResponse.requestId,\n ephemeralWalletAddress: buildResponse.ephemeralWalletAddress,\n };\n }\n\n async getDetails(\n request: PaymentRequestDetailsRequest,\n ): Promise<ServiceResponse<PaymentRequestDetailsResponse>> {\n return this.apiClient.payments.getPaymentRequestDetails(request);\n }\n\n async list(\n request: GetPaymentRequestsRequest,\n ): Promise<PaginatedServiceResponse<GetPaymentRequestsResponse>> {\n return this.apiClient.payments.getPaymentRequests(request);\n }\n\n private async activate(\n buildResponse: PaymentResponseWithActionNames,\n settlementChainId: number,\n ): Promise<void> {\n const publicClient = this.createPublicClient(settlementChainId);\n\n const instructions = [\n ...buildResponse.completionInstructions,\n ...buildResponse.instructions,\n ];\n\n const delegateAddressMap = await this.fetchDelegateAddresses(instructions);\n\n const {\n signedAuthorization,\n completionInstructions,\n instructions: signedInstructions,\n } = await createPaymentSigner({\n context: this.context,\n buildResponse,\n publicClient,\n delegateAddressMap,\n });\n\n await this.apiClient.payments.newPaymentRequest({\n requestId: buildResponse.requestId,\n signedAuthorization,\n completionInstructions,\n instructions: signedInstructions,\n });\n }\n\n private async buildAndEnhancePaymentRequest(\n payload: PaymentRequestBuildRequest,\n ): Promise<PaymentResponseWithActionNames> {\n const actionNames = extractActionNamesMap(\n payload.completionInstructions,\n payload.instructions,\n );\n\n const response = await this.apiClient.payments.buildPaymentRequest(payload);\n\n return addActionNamesToInstructions(response.data, actionNames);\n }\n\n private createPublicClient(chainId: number): PublicClient {\n const chain = getChainById(chainId);\n if (!chain) {\n throw new Error(`Chain with id ${chainId} not found`);\n }\n\n return createPublicClient({ chain, transport: http() });\n }\n\n private async fetchDelegateAddresses(\n instructions: PaymentInstruction[],\n ): Promise<Map<number, Address>> {\n const chainIds = Array.from(\n new Set(instructions.map((instruction) => instruction.chainId)),\n );\n\n const addresses = await Promise.all(\n chainIds.map(async (chainId) => {\n const response = await this.apiClient.config.getDelegateAddress({\n chainId,\n });\n const address = hexStringSchema.parse(\n response.data.otimDelegateAddress,\n );\n return [chainId, address] as const;\n }),\n );\n\n return new Map(addresses);\n }\n}\n","import type { PaymentRequestBuildRequest } from \"@otim/utils/api\";\nimport type { SupportedChainId } from \"@otim/utils/chains\";\nimport type { Nullable } from \"@otim/utils/helpers\";\nimport type { PaymentRequestMetadata } from \"@otim/utils/payments\";\nimport type { Address } from \"@otim/utils/schemas\";\n\nimport {\n getChainTokens,\n getTokenAddress,\n getTokenMetadata,\n supportedChains,\n} from \"@otim/utils/chains\";\nimport { validateIso8601Date } from \"@otim/utils/helpers\";\nimport {\n buildPaymentMetadata,\n createChainTokenConfigs,\n createComprehensivePaymentRequest,\n} from \"@otim/utils/payments\";\nimport { hexStringSchema } from \"@otim/utils/schemas\";\n\nexport interface PreparePaymentRequestParams {\n amount: number;\n chainId: SupportedChainId;\n recipient: Address;\n token?: \"USDC\" | \"USDT\";\n payer?: Nullable<Address>;\n dueDate?: string;\n metadata?: PaymentRequestMetadata;\n note?: string;\n maxRuns?: number;\n}\n\nexport interface PreparedPaymentRequest {\n payload: PaymentRequestBuildRequest;\n chainId: number;\n}\n\nfunction validateAndGetTokenAddress(chainId: number, token: string): Address {\n const tokenAddress = getTokenAddress(chainId, token);\n if (!tokenAddress) {\n throw new Error(`Token ${token} not supported on chain ${chainId}`);\n }\n\n const tokenMetadata = getTokenMetadata(token);\n if (!tokenMetadata) {\n throw new Error(`Token ${token} metadata not found`);\n }\n\n return hexStringSchema.parse(tokenAddress);\n}\n\nfunction buildMetadataFromParams(params: {\n token: string;\n amount: number;\n recipient: Address;\n note?: string;\n dueDate?: string;\n customMetadata?: PaymentRequestMetadata;\n}): PaymentRequestMetadata {\n const { token, amount, recipient, note, dueDate, customMetadata } = params;\n\n const baseMetadata = buildPaymentMetadata({\n tokenSymbol: token,\n amountInUSD: amount,\n fromAccountAddress: recipient,\n note,\n dueDate,\n hasInvoiceMetadata: false,\n });\n\n return customMetadata ? { ...baseMetadata, ...customMetadata } : baseMetadata;\n}\n\nfunction createPayload(params: {\n chainId: number;\n recipient: Address;\n amount: number;\n payer?: Address | null;\n metadata: PaymentRequestMetadata;\n feeTokenAddress: Address;\n maxRuns?: number;\n}): PaymentRequestBuildRequest {\n const {\n chainId,\n recipient,\n amount,\n payer,\n metadata,\n feeTokenAddress,\n maxRuns,\n } = params;\n\n const tokens = Object.values(supportedChains.mainnet).flatMap((chain) =>\n getChainTokens(chain.id),\n );\n\n const chainTokenConfigs = createChainTokenConfigs(tokens);\n\n return createComprehensivePaymentRequest({\n settlementChainId: chainId,\n recipient,\n amount: amount.toString(),\n ephemeralWalletAddress: recipient,\n chainTokenConfigs,\n payerAddress: payer ?? null,\n metadata,\n feeToken: feeTokenAddress,\n maxRuns,\n });\n}\n\nexport function preparePaymentRequest(\n params: PreparePaymentRequestParams,\n): PreparedPaymentRequest {\n const {\n chainId,\n token = \"USDC\",\n recipient,\n amount,\n payer,\n note,\n dueDate,\n metadata: customMetadata,\n maxRuns,\n } = params;\n\n if (dueDate) {\n validateIso8601Date(dueDate);\n }\n\n const feeTokenAddress = validateAndGetTokenAddress(chainId, token);\n const metadata = buildMetadataFromParams({\n token,\n amount,\n recipient,\n note,\n dueDate,\n customMetadata,\n });\n\n const payload = createPayload({\n chainId,\n recipient,\n amount,\n payer,\n metadata,\n feeTokenAddress,\n maxRuns,\n });\n\n return { payload, chainId };\n}\n"],"mappings":";;;;;;;;;;;;AAMA,IAAa,iBAAb,MAA4B;CAC1B,YAAY,AAAiBA,WAAsB;EAAtB;;CAE7B,MAAM,uBACJ,SACyC;AAIzC,UAFE,MAAM,KAAK,UAAU,SAAS,uBAAuB,QAAQ,EAE/C;;;;;;ACDpB,IAAa,aAAb,MAAwB;CACtB,YACE,AAAiBC,WACjB,AAAiBC,SACjB,AAAiBC,SACjB;EAHiB;EACA;EACA;;CAGnB,MAAM,MAAM,EAAE,WAAqD;AACjE,qBAAmB,KAAK,QAAQ;EAEhC,MAAM,UAAU,uBAAuB,SAAS,KAAK,KAAK,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,QACA,OACA,MACA,SACA,UAAU,gBACV,YACE;AAEJ,KAAI,QACF,qBAAoB,QAAQ;CAG9B,MAAM,kBAAkB,2BAA2B,SAAS,MAAM;AAoBlE,QAAO;EAAE,SAVO,cAAc;GAC5B;GACA;GACA;GACA;GACA,UAde,wBAAwB;IACvC;IACA;IACA;IACA;IACA;IACA;IACD,CAAC;GAQA;GACA;GACD,CAAC;EAEgB;EAAS"}
|
package/dist/config/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../abi-
|
|
2
|
-
import { a as env, c as isEnvironment, i as Environment, n as SIWE_VERSION, o as getApiUrl, r as createLoginSiweMessage, s as getTurnkeyApiUrl, t as SIWE_CHAIN_ID } from "../index-
|
|
1
|
+
import "../abi-OUq-mx1W.cjs";
|
|
2
|
+
import { a as env, c as isEnvironment, i as Environment, n as SIWE_VERSION, o as getApiUrl, r as createLoginSiweMessage, s as getTurnkeyApiUrl, t as SIWE_CHAIN_ID } from "../index-lW-Oor1B.cjs";
|
|
3
3
|
export { Environment, Environment as EnvironmentType, SIWE_CHAIN_ID, SIWE_VERSION, createLoginSiweMessage, env, getApiUrl, getTurnkeyApiUrl, isEnvironment };
|
package/dist/config/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../abi-
|
|
2
|
-
import { a as env, c as isEnvironment, i as Environment, n as SIWE_VERSION, o as getApiUrl, r as createLoginSiweMessage, s as getTurnkeyApiUrl, t as SIWE_CHAIN_ID } from "../index-
|
|
1
|
+
import "../abi-DW6AS0eM.mjs";
|
|
2
|
+
import { a as env, c as isEnvironment, i as Environment, n as SIWE_VERSION, o as getApiUrl, r as createLoginSiweMessage, s as getTurnkeyApiUrl, t as SIWE_CHAIN_ID } from "../index-D_7CTJDl.mjs";
|
|
3
3
|
export { Environment, Environment as EnvironmentType, SIWE_CHAIN_ID, SIWE_VERSION, createLoginSiweMessage, env, getApiUrl, getTurnkeyApiUrl, isEnvironment };
|
package/dist/context/index.d.cts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../abi-OUq-mx1W.cjs";
|
|
2
|
+
import "../rpc-BDoNl1Sp.cjs";
|
|
3
|
+
import "../authorization-6anhDdQX.cjs";
|
|
4
|
+
import { a as OtimReactClientContext, i as OtimClientContext, n as assertRequiresAuth, o as OtimServerClientContext, r as assertServerContext, t as isServerContext } from "../index-GSspyLr3.cjs";
|
|
2
5
|
export { OtimClientContext, OtimReactClientContext, OtimServerClientContext, assertRequiresAuth, assertServerContext, isServerContext };
|
package/dist/context/index.d.mts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../abi-DW6AS0eM.mjs";
|
|
2
|
+
import "../rpc-CygBD_f7.mjs";
|
|
3
|
+
import "../authorization-DnNpWjxB.mjs";
|
|
4
|
+
import { a as OtimReactClientContext, i as OtimClientContext, n as assertRequiresAuth, o as OtimServerClientContext, r as assertServerContext, t as isServerContext } from "../index-DWE1xfOE.mjs";
|
|
2
5
|
export { OtimClientContext, OtimReactClientContext, OtimServerClientContext, assertRequiresAuth, assertServerContext, isServerContext };
|