@otim/sdk-core 0.0.3 → 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.
Files changed (80) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/abi-DW6AS0eM.d.mts +339 -0
  3. package/dist/abi-DW6AS0eM.d.mts.map +1 -0
  4. package/dist/abi-OUq-mx1W.d.cts +339 -0
  5. package/dist/abi-OUq-mx1W.d.cts.map +1 -0
  6. package/dist/account/index.cjs +1 -1
  7. package/dist/account/index.d.cts +5 -3
  8. package/dist/account/index.d.mts +5 -3
  9. package/dist/account/index.mjs +1 -1
  10. package/dist/{account-Bwm5PTcc.cjs → account-CRvC_dXT.cjs} +8 -3
  11. package/dist/account-CRvC_dXT.cjs.map +1 -0
  12. package/dist/{account-p4sxzIt3.mjs → account-D1NVta26.mjs} +8 -3
  13. package/dist/account-D1NVta26.mjs.map +1 -0
  14. package/dist/authorization-6anhDdQX.d.cts +210 -0
  15. package/dist/authorization-6anhDdQX.d.cts.map +1 -0
  16. package/dist/authorization-DnNpWjxB.d.mts +210 -0
  17. package/dist/authorization-DnNpWjxB.d.mts.map +1 -0
  18. package/dist/clients/index.cjs +2 -2
  19. package/dist/clients/index.d.cts +3 -3
  20. package/dist/clients/index.d.mts +3 -3
  21. package/dist/clients/index.mjs +2 -2
  22. package/dist/{clients-CVg-yW5b.cjs → clients-BCyzdTLc.cjs} +73 -127
  23. package/dist/clients-BCyzdTLc.cjs.map +1 -0
  24. package/dist/{clients-DnPvBXkX.mjs → clients-Bn4BUElo.mjs} +72 -126
  25. package/dist/clients-Bn4BUElo.mjs.map +1 -0
  26. package/dist/config/index.d.cts +2 -2
  27. package/dist/config/index.d.mts +2 -2
  28. package/dist/context/index.d.cts +4 -1
  29. package/dist/context/index.d.mts +4 -1
  30. package/dist/{index-DW_zBRKz.d.mts → index-BQMXYh9N.d.cts} +2 -13
  31. package/dist/index-BQMXYh9N.d.cts.map +1 -0
  32. package/dist/{index-B4fkcFy5.d.mts → index-C5c51xs0.d.mts} +5 -8
  33. package/dist/index-C5c51xs0.d.mts.map +1 -0
  34. package/dist/{index-DK-40z4V.d.cts → index-C8H-BPGH.d.cts} +5 -8
  35. package/dist/index-C8H-BPGH.d.cts.map +1 -0
  36. package/dist/{index-747pyuMH.d.mts → index-Ce_qYSJj.d.cts} +25 -38
  37. package/dist/index-Ce_qYSJj.d.cts.map +1 -0
  38. package/dist/{index-BH1YuouL.d.cts → index-CiyyA-wd.d.mts} +25 -38
  39. package/dist/index-CiyyA-wd.d.mts.map +1 -0
  40. package/dist/{index-BnP8vpJJ.d.cts → index-CnjY7cyS.d.mts} +2 -13
  41. package/dist/index-CnjY7cyS.d.mts.map +1 -0
  42. package/dist/{index-CcCMIBgF.d.mts → index-DWE1xfOE.d.mts} +4 -1
  43. package/dist/index-DWE1xfOE.d.mts.map +1 -0
  44. package/dist/{index-UnaahQgb.d.cts → index-D_7CTJDl.d.mts} +2 -2
  45. package/dist/{index-C4N2Xixk.d.mts.map → index-D_7CTJDl.d.mts.map} +1 -1
  46. package/dist/{index-C1HSAemv.d.cts → index-GSspyLr3.d.cts} +4 -1
  47. package/dist/index-GSspyLr3.d.cts.map +1 -0
  48. package/dist/{index-C4N2Xixk.d.mts → index-lW-Oor1B.d.cts} +2 -2
  49. package/dist/{index-UnaahQgb.d.cts.map → index-lW-Oor1B.d.cts.map} +1 -1
  50. package/dist/index.cjs +4 -4
  51. package/dist/index.d.cts +9 -8
  52. package/dist/index.d.mts +9 -8
  53. package/dist/index.mjs +3 -3
  54. package/dist/rpc-BDoNl1Sp.d.cts +6885 -0
  55. package/dist/rpc-BDoNl1Sp.d.cts.map +1 -0
  56. package/dist/rpc-CygBD_f7.d.mts +6885 -0
  57. package/dist/rpc-CygBD_f7.d.mts.map +1 -0
  58. package/dist/utils/index.d.cts +3 -3
  59. package/dist/utils/index.d.mts +3 -3
  60. package/package.json +3 -3
  61. package/dist/abi-Bd3X6gV9.d.mts +0 -154
  62. package/dist/abi-Bd3X6gV9.d.mts.map +0 -1
  63. package/dist/abi-CQuxrNCU.d.cts +0 -154
  64. package/dist/abi-CQuxrNCU.d.cts.map +0 -1
  65. package/dist/account-Bwm5PTcc.cjs.map +0 -1
  66. package/dist/account-p4sxzIt3.mjs.map +0 -1
  67. package/dist/clients-CVg-yW5b.cjs.map +0 -1
  68. package/dist/clients-DnPvBXkX.mjs.map +0 -1
  69. package/dist/index-747pyuMH.d.mts.map +0 -1
  70. package/dist/index-B4fkcFy5.d.mts.map +0 -1
  71. package/dist/index-BH1YuouL.d.cts.map +0 -1
  72. package/dist/index-BnP8vpJJ.d.cts.map +0 -1
  73. package/dist/index-C1HSAemv.d.cts.map +0 -1
  74. package/dist/index-CcCMIBgF.d.mts.map +0 -1
  75. package/dist/index-DK-40z4V.d.cts.map +0 -1
  76. package/dist/index-DW_zBRKz.d.mts.map +0 -1
  77. package/dist/misc-CX4pLJaA.d.mts +0 -42
  78. package/dist/misc-CX4pLJaA.d.mts.map +0 -1
  79. package/dist/misc-CpZxSPCP.d.cts +0 -42
  80. package/dist/misc-CpZxSPCP.d.cts.map +0 -1
@@ -95,46 +95,30 @@ async function createPaymentSigner(params) {
95
95
  }
96
96
 
97
97
  //#endregion
98
- //#region src/clients/payment-requests.ts
99
- var PaymentRequestsClient = class {
98
+ //#region src/clients/orchestration.ts
99
+ var OrchestrationClient = class {
100
100
  constructor(apiClient, account, context) {
101
101
  this.apiClient = apiClient;
102
102
  this.account = account;
103
103
  this.context = context;
104
104
  }
105
- async create(params) {
106
- const { chainId, token = "USDC", recipient, amount, payer, note, dueDate, metadata: customMetadata } = params;
107
- if (dueDate) (0, __otim_utils_helpers.validateIso8601Date)(dueDate);
108
- const feeTokenAddress = this.validateAndGetTokenAddress(chainId, token);
109
- const metadata = this.buildMetadata({
110
- token,
111
- amount,
112
- recipient,
113
- note,
114
- dueDate,
115
- customMetadata
116
- });
117
- const payload = this.createPayload({
118
- chainId,
119
- recipient,
120
- amount,
121
- payer,
122
- metadata,
123
- feeTokenAddress
124
- });
105
+ async create(preparedRequest) {
106
+ (0, __otim_sdk_core_context.assertServerContext)(this.context);
107
+ const { payload, chainId } = preparedRequest;
125
108
  const buildResponse = await this.buildAndEnhancePaymentRequest(payload);
126
- await this.activate({
127
- buildResponse,
128
- settlementChainId: chainId
129
- });
109
+ await this.activate(buildResponse, chainId);
130
110
  return {
131
111
  requestId: buildResponse.requestId,
132
112
  ephemeralWalletAddress: buildResponse.ephemeralWalletAddress
133
113
  };
134
114
  }
135
- async activate(params) {
136
- (0, __otim_sdk_core_context.assertServerContext)(this.context);
137
- const { buildResponse, settlementChainId } = params;
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) {
138
122
  const publicClient = this.createPublicClient(settlementChainId);
139
123
  const instructions = [...buildResponse.completionInstructions, ...buildResponse.instructions];
140
124
  const delegateAddressMap = await this.fetchDelegateAddresses(instructions);
@@ -151,41 +135,6 @@ var PaymentRequestsClient = class {
151
135
  instructions: signedInstructions
152
136
  });
153
137
  }
154
- validateAndGetTokenAddress(chainId, token) {
155
- const tokenAddress = (0, __otim_utils_chains.getTokenAddress)(chainId, token);
156
- if (!tokenAddress) throw new Error(`Token ${token} not supported on chain ${chainId}`);
157
- if (!(0, __otim_utils_chains.getTokenMetadata)(token)) throw new Error(`Token ${token} metadata not found`);
158
- return __otim_utils_schemas.hexStringSchema.parse(tokenAddress);
159
- }
160
- buildMetadata(params) {
161
- const { token, amount, recipient, note, dueDate, customMetadata } = params;
162
- const baseMetadata = (0, __otim_utils_payments.buildPaymentMetadata)({
163
- tokenSymbol: token,
164
- amountInUSD: amount,
165
- fromAccountAddress: recipient,
166
- note,
167
- dueDate,
168
- hasInvoiceMetadata: false
169
- });
170
- return customMetadata ? {
171
- ...baseMetadata,
172
- ...customMetadata
173
- } : baseMetadata;
174
- }
175
- createPayload(params) {
176
- const { chainId, recipient, amount, payer, metadata, feeTokenAddress } = params;
177
- const chainTokenConfigs = (0, __otim_utils_payments.createChainTokenConfigs)(Object.values(__otim_utils_chains.supportedChains.mainnet).flatMap((chain) => (0, __otim_utils_chains.getChainTokens)(chain.id)));
178
- return (0, __otim_utils_payments.createComprehensivePaymentRequest)({
179
- settlementChainId: chainId,
180
- recipient,
181
- amount: amount.toString(),
182
- ephemeralWalletAddress: recipient,
183
- chainTokenConfigs,
184
- payerAddress: payer ?? null,
185
- metadata,
186
- feeToken: feeTokenAddress
187
- });
188
- }
189
138
  async buildAndEnhancePaymentRequest(payload) {
190
139
  const actionNames = (0, __otim_utils_payments.extractActionNamesMap)(payload.completionInstructions, payload.instructions);
191
140
  return (0, __otim_utils_payments.addActionNamesToInstructions)((await this.apiClient.payments.buildPaymentRequest(payload)).data, actionNames);
@@ -206,74 +155,71 @@ var PaymentRequestsClient = class {
206
155
  }));
207
156
  return new Map(addresses);
208
157
  }
209
- async getDetails(request) {
210
- return this.apiClient.payments.getPaymentRequestDetails(request);
211
- }
212
- async listOutgoingPaymentRequests(request) {
213
- return this.apiClient.payments.getOutgoingPaymentsList(request);
214
- }
215
- async listIncomingPaymentRequests(request) {
216
- return this.apiClient.payments.getIncomingPaymentsList(request);
217
- }
218
- async list(request) {
219
- return this.apiClient.payments.getPaymentRequests(request);
220
- }
221
158
  };
222
159
 
223
160
  //#endregion
224
- //#region \0@oxc-project+runtime@0.97.0/helpers/typeof.js
225
- function _typeof(o) {
226
- "@babel/helpers - typeof";
227
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
228
- return typeof o$1;
229
- } : function(o$1) {
230
- return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
231
- }, _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);
232
167
  }
233
-
234
- //#endregion
235
- //#region \0@oxc-project+runtime@0.97.0/helpers/toPrimitive.js
236
- function toPrimitive(t, r) {
237
- if ("object" != _typeof(t) || !t) return t;
238
- var e = t[Symbol.toPrimitive];
239
- if (void 0 !== e) {
240
- var i = e.call(t, r || "default");
241
- if ("object" != _typeof(i)) return i;
242
- throw new TypeError("@@toPrimitive must return a primitive value.");
243
- }
244
- return ("string" === r ? String : Number)(t);
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;
245
182
  }
246
-
247
- //#endregion
248
- //#region \0@oxc-project+runtime@0.97.0/helpers/toPropertyKey.js
249
- function toPropertyKey(t) {
250
- var i = toPrimitive(t, "string");
251
- return "symbol" == _typeof(i) ? i : i + "";
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
+ });
252
197
  }
253
-
254
- //#endregion
255
- //#region \0@oxc-project+runtime@0.97.0/helpers/defineProperty.js
256
- function _defineProperty(e, r, t) {
257
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
258
- value: t,
259
- enumerable: !0,
260
- configurable: !0,
261
- writable: !0
262
- }) : e[r] = t, e;
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
+ };
263
221
  }
264
222
 
265
- //#endregion
266
- //#region src/clients/orchestration.ts
267
- var OrchestrationClient = class {
268
- constructor(apiClient, account, context) {
269
- this.apiClient = apiClient;
270
- this.account = account;
271
- this.context = context;
272
- _defineProperty(this, "paymentRequests", void 0);
273
- this.paymentRequests = new PaymentRequestsClient(apiClient, account, context);
274
- }
275
- };
276
-
277
223
  //#endregion
278
224
  Object.defineProperty(exports, 'ActivityClient', {
279
225
  enumerable: true,
@@ -305,10 +251,10 @@ Object.defineProperty(exports, 'OrchestrationClient', {
305
251
  return OrchestrationClient;
306
252
  }
307
253
  });
308
- Object.defineProperty(exports, 'PaymentRequestsClient', {
254
+ Object.defineProperty(exports, 'preparePaymentRequest', {
309
255
  enumerable: true,
310
256
  get: function () {
311
- return PaymentRequestsClient;
257
+ return preparePaymentRequest;
312
258
  }
313
259
  });
314
- //# sourceMappingURL=clients-CVg-yW5b.cjs.map
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,IAA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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"}
@@ -95,46 +95,30 @@ async function createPaymentSigner(params) {
95
95
  }
96
96
 
97
97
  //#endregion
98
- //#region src/clients/payment-requests.ts
99
- var PaymentRequestsClient = class {
98
+ //#region src/clients/orchestration.ts
99
+ var OrchestrationClient = class {
100
100
  constructor(apiClient, account, context) {
101
101
  this.apiClient = apiClient;
102
102
  this.account = account;
103
103
  this.context = context;
104
104
  }
105
- async create(params) {
106
- const { chainId, token = "USDC", recipient, amount, payer, note, dueDate, metadata: customMetadata } = params;
107
- if (dueDate) validateIso8601Date(dueDate);
108
- const feeTokenAddress = this.validateAndGetTokenAddress(chainId, token);
109
- const metadata = this.buildMetadata({
110
- token,
111
- amount,
112
- recipient,
113
- note,
114
- dueDate,
115
- customMetadata
116
- });
117
- const payload = this.createPayload({
118
- chainId,
119
- recipient,
120
- amount,
121
- payer,
122
- metadata,
123
- feeTokenAddress
124
- });
105
+ async create(preparedRequest) {
106
+ assertServerContext(this.context);
107
+ const { payload, chainId } = preparedRequest;
125
108
  const buildResponse = await this.buildAndEnhancePaymentRequest(payload);
126
- await this.activate({
127
- buildResponse,
128
- settlementChainId: chainId
129
- });
109
+ await this.activate(buildResponse, chainId);
130
110
  return {
131
111
  requestId: buildResponse.requestId,
132
112
  ephemeralWalletAddress: buildResponse.ephemeralWalletAddress
133
113
  };
134
114
  }
135
- async activate(params) {
136
- assertServerContext(this.context);
137
- const { buildResponse, settlementChainId } = params;
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) {
138
122
  const publicClient = this.createPublicClient(settlementChainId);
139
123
  const instructions = [...buildResponse.completionInstructions, ...buildResponse.instructions];
140
124
  const delegateAddressMap = await this.fetchDelegateAddresses(instructions);
@@ -151,41 +135,6 @@ var PaymentRequestsClient = class {
151
135
  instructions: signedInstructions
152
136
  });
153
137
  }
154
- validateAndGetTokenAddress(chainId, token) {
155
- const tokenAddress = getTokenAddress(chainId, token);
156
- if (!tokenAddress) throw new Error(`Token ${token} not supported on chain ${chainId}`);
157
- if (!getTokenMetadata(token)) throw new Error(`Token ${token} metadata not found`);
158
- return hexStringSchema.parse(tokenAddress);
159
- }
160
- buildMetadata(params) {
161
- const { token, amount, recipient, note, dueDate, customMetadata } = params;
162
- const baseMetadata = buildPaymentMetadata({
163
- tokenSymbol: token,
164
- amountInUSD: amount,
165
- fromAccountAddress: recipient,
166
- note,
167
- dueDate,
168
- hasInvoiceMetadata: false
169
- });
170
- return customMetadata ? {
171
- ...baseMetadata,
172
- ...customMetadata
173
- } : baseMetadata;
174
- }
175
- createPayload(params) {
176
- const { chainId, recipient, amount, payer, metadata, feeTokenAddress } = params;
177
- const chainTokenConfigs = createChainTokenConfigs(Object.values(supportedChains.mainnet).flatMap((chain) => getChainTokens(chain.id)));
178
- return createComprehensivePaymentRequest({
179
- settlementChainId: chainId,
180
- recipient,
181
- amount: amount.toString(),
182
- ephemeralWalletAddress: recipient,
183
- chainTokenConfigs,
184
- payerAddress: payer ?? null,
185
- metadata,
186
- feeToken: feeTokenAddress
187
- });
188
- }
189
138
  async buildAndEnhancePaymentRequest(payload) {
190
139
  const actionNames = extractActionNamesMap(payload.completionInstructions, payload.instructions);
191
140
  return addActionNamesToInstructions((await this.apiClient.payments.buildPaymentRequest(payload)).data, actionNames);
@@ -206,74 +155,71 @@ var PaymentRequestsClient = class {
206
155
  }));
207
156
  return new Map(addresses);
208
157
  }
209
- async getDetails(request) {
210
- return this.apiClient.payments.getPaymentRequestDetails(request);
211
- }
212
- async listOutgoingPaymentRequests(request) {
213
- return this.apiClient.payments.getOutgoingPaymentsList(request);
214
- }
215
- async listIncomingPaymentRequests(request) {
216
- return this.apiClient.payments.getIncomingPaymentsList(request);
217
- }
218
- async list(request) {
219
- return this.apiClient.payments.getPaymentRequests(request);
220
- }
221
158
  };
222
159
 
223
160
  //#endregion
224
- //#region \0@oxc-project+runtime@0.97.0/helpers/typeof.js
225
- function _typeof(o) {
226
- "@babel/helpers - typeof";
227
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
228
- return typeof o$1;
229
- } : function(o$1) {
230
- return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
231
- }, _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);
232
167
  }
233
-
234
- //#endregion
235
- //#region \0@oxc-project+runtime@0.97.0/helpers/toPrimitive.js
236
- function toPrimitive(t, r) {
237
- if ("object" != _typeof(t) || !t) return t;
238
- var e = t[Symbol.toPrimitive];
239
- if (void 0 !== e) {
240
- var i = e.call(t, r || "default");
241
- if ("object" != _typeof(i)) return i;
242
- throw new TypeError("@@toPrimitive must return a primitive value.");
243
- }
244
- return ("string" === r ? String : Number)(t);
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;
245
182
  }
246
-
247
- //#endregion
248
- //#region \0@oxc-project+runtime@0.97.0/helpers/toPropertyKey.js
249
- function toPropertyKey(t) {
250
- var i = toPrimitive(t, "string");
251
- return "symbol" == _typeof(i) ? i : i + "";
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
+ });
252
197
  }
253
-
254
- //#endregion
255
- //#region \0@oxc-project+runtime@0.97.0/helpers/defineProperty.js
256
- function _defineProperty(e, r, t) {
257
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
258
- value: t,
259
- enumerable: !0,
260
- configurable: !0,
261
- writable: !0
262
- }) : e[r] = t, e;
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
+ };
263
221
  }
264
222
 
265
223
  //#endregion
266
- //#region src/clients/orchestration.ts
267
- var OrchestrationClient = class {
268
- constructor(apiClient, account, context) {
269
- this.apiClient = apiClient;
270
- this.account = account;
271
- this.context = context;
272
- _defineProperty(this, "paymentRequests", void 0);
273
- this.paymentRequests = new PaymentRequestsClient(apiClient, account, context);
274
- }
275
- };
276
-
277
- //#endregion
278
- export { AuthClient as a, ConfigClient as i, PaymentRequestsClient as n, ActivityClient as o, DelegationClient as r, OrchestrationClient as t };
279
- //# sourceMappingURL=clients-DnPvBXkX.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,CAAC,UAAU,CAAC;EAEtE,MAAM,qBAAqB,oBADT,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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M;AACpD,KAAI,CAAC,aACH,OAAM,IAAI,MAAM,SAAS,MAAM,0BAA0B,UAAU;AAIrE,KAAI,CADkB,iBAAiB,MAAM,CAE3C,OAAM,IAAI,MAAM,SAAS,MAAM,qBAAqB;AAGtD,QAAO,gBAAgB,MAAM,aAAa;;AAG5C,SAAS,wBAAwB,QAON;CACzB,MAAM,EAAE,OAAO,QAAQ,WAAW,MAAM,SAAS,mBAAmB;CAEpE,MAAM,eAAe,qBAAqB;EACxC,aAAa;EACb,aAAa;EACb,oBAAoB;EACpB;EACA;EACA,oBAAoB;EACrB,CAAC;AAEF,QAAO,iBAAiB;EAAE,GAAG;EAAc,GAAG;EAAgB,GAAG;;AAGnE,SAAS,cAAc,QAQQ;CAC7B,MAAM,EACJ,SACA,WACA,QACA,OACA,UACA,iBACA,YACE;CAMJ,MAAM,oBAAoB,wBAJX,OAAO,OAAO,gBAAgB,QAAQ,CAAC,SAAS,UAC7D,eAAe,MAAM,GAAG,CACzB,CAEwD;AAEzD,QAAO,kCAAkC;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,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"}
@@ -1,3 +1,3 @@
1
- import "../abi-CQuxrNCU.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-UnaahQgb.cjs";
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 };
@@ -1,3 +1,3 @@
1
- import "../abi-Bd3X6gV9.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-C4N2Xixk.mjs";
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 };
@@ -1,2 +1,5 @@
1
- import { a as OtimReactClientContext, i as OtimClientContext, n as assertRequiresAuth, o as OtimServerClientContext, r as assertServerContext, t as isServerContext } from "../index-C1HSAemv.cjs";
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 };
@@ -1,2 +1,5 @@
1
- import { a as OtimReactClientContext, i as OtimClientContext, n as assertRequiresAuth, o as OtimServerClientContext, r as assertServerContext, t as isServerContext } from "../index-CcCMIBgF.mjs";
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 };
@@ -1,17 +1,6 @@
1
- import { t as Address$1 } from "./abi-Bd3X6gV9.mjs";
2
- import { n as Signature, r as ExactPartial } from "./misc-CX4pLJaA.mjs";
1
+ import { t as Authorization } from "./authorization-6anhDdQX.cjs";
3
2
  import { EIP2098Signature, VRS } from "@otim/utils/schemas";
4
3
 
5
- //#region ../../node_modules/.pnpm/viem@2.39.3_bufferutil@4.0.9_typescript@5.9.3_utf-8-validate@5.0.10_zod@4.1.12/node_modules/viem/_types/types/authorization.d.ts
6
- type Authorization<uint32 = number, signed extends boolean = false> = {
7
- /** Address of the contract to delegate to. */
8
- address: Address$1;
9
- /** Chain ID. */
10
- chainId: uint32;
11
- /** Nonce of the EOA to delegate to. */
12
- nonce: uint32;
13
- } & (signed extends true ? Signature<uint32> : ExactPartial<Signature<uint32>>);
14
- //#endregion
15
4
  //#region src/utils/rlp.d.ts
16
5
  declare const normalizeYParityValue: (value: number | bigint | string | undefined | null) => 0 | 1;
17
6
  declare function createRlpEncodedAuthorization(authorization: Authorization): `0x${string}`;
@@ -22,4 +11,4 @@ declare const createEIP2098Signature: (vrs: VRS) => EIP2098Signature;
22
11
  declare const parseSignatureToVRS: (signature: string) => VRS;
23
12
  //#endregion
24
13
  export { normalizeYParityValue as i, parseSignatureToVRS as n, createRlpEncodedAuthorization as r, createEIP2098Signature as t };
25
- //# sourceMappingURL=index-DW_zBRKz.d.mts.map
14
+ //# sourceMappingURL=index-BQMXYh9N.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BQMXYh9N.d.cts","names":[],"sources":["../src/utils/rlp.ts","../src/utils/vrs.ts"],"sourcesContent":[],"mappings":";;;;cAuBa;iBAkCG,6BAAA,gBACC;iBAED,6BAAA;;;cCrBH,8BAA+B,QAAM;cAkBrC,4CAA2C"}