@coinbase/cdp-sdk 1.29.0 → 1.31.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/CHANGELOG.md +16 -0
- package/_cjs/accounts/evm/networkCapabilities.js +101 -0
- package/_cjs/accounts/evm/networkCapabilities.js.map +1 -1
- package/_cjs/accounts/evm/toEvmServerAccount.js +11 -0
- package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toEvmSmartAccount.js +11 -0
- package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js +10 -0
- package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +10 -0
- package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_cjs/accounts/solana/toSolanaAccount.js +11 -1
- package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_cjs/actions/evm/getUserOperation.js +1 -0
- package/_cjs/actions/evm/getUserOperation.js.map +1 -1
- package/_cjs/actions/evm/spend-permissions/account.use.js +33 -0
- package/_cjs/actions/evm/spend-permissions/account.use.js.map +1 -0
- package/_cjs/actions/evm/spend-permissions/smartAccount.use.js +35 -0
- package/_cjs/actions/evm/spend-permissions/smartAccount.use.js.map +1 -0
- package/_cjs/actions/evm/spend-permissions/types.js +3 -0
- package/_cjs/actions/evm/spend-permissions/types.js.map +1 -0
- package/_cjs/actions/solana/sendTransaction.js +1 -0
- package/_cjs/actions/solana/sendTransaction.js.map +1 -1
- package/_cjs/actions/solana/signTransaction.js +1 -0
- package/_cjs/actions/solana/signTransaction.js.map +1 -1
- package/_cjs/auth/hooks/axios/withAuth.js +3 -0
- package/_cjs/auth/hooks/axios/withAuth.js.map +1 -1
- package/_cjs/auth/utils/http.js +2 -1
- package/_cjs/auth/utils/http.js.map +1 -1
- package/_cjs/client/evm/evm.js +51 -1
- package/_cjs/client/evm/evm.js.map +1 -1
- package/_cjs/client/solana/solana.js.map +1 -1
- package/_cjs/index.js +5 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/openapi-client/cdpApiClient.js +37 -0
- package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +29 -2
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +35 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +160 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/index.msw.js +1 -0
- package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
- package/_cjs/openapi-client/generated/onramp/onramp.js +30 -0
- package/_cjs/openapi-client/generated/onramp/onramp.js.map +1 -0
- package/_cjs/openapi-client/generated/onramp/onramp.msw.js +98 -0
- package/_cjs/openapi-client/generated/onramp/onramp.msw.js.map +1 -0
- package/_cjs/openapi-client/index.js +1 -0
- package/_cjs/openapi-client/index.js.map +1 -1
- package/_cjs/spend-permissions/constants.js +716 -0
- package/_cjs/spend-permissions/constants.js.map +1 -0
- package/_cjs/spend-permissions/types.js +3 -0
- package/_cjs/spend-permissions/types.js.map +1 -0
- package/_cjs/version.js +1 -1
- package/_esm/accounts/evm/networkCapabilities.js +101 -0
- package/_esm/accounts/evm/networkCapabilities.js.map +1 -1
- package/_esm/accounts/evm/toEvmServerAccount.js +11 -0
- package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toEvmSmartAccount.js +11 -0
- package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +10 -0
- package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +10 -0
- package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
- package/_esm/accounts/solana/toSolanaAccount.js +11 -1
- package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
- package/_esm/actions/evm/getUserOperation.js +1 -0
- package/_esm/actions/evm/getUserOperation.js.map +1 -1
- package/_esm/actions/evm/spend-permissions/account.use.js +30 -0
- package/_esm/actions/evm/spend-permissions/account.use.js.map +1 -0
- package/_esm/actions/evm/spend-permissions/smartAccount.use.js +32 -0
- package/_esm/actions/evm/spend-permissions/smartAccount.use.js.map +1 -0
- package/_esm/actions/evm/spend-permissions/types.js +2 -0
- package/_esm/actions/evm/spend-permissions/types.js.map +1 -0
- package/_esm/actions/solana/sendTransaction.js +1 -0
- package/_esm/actions/solana/sendTransaction.js.map +1 -1
- package/_esm/actions/solana/signTransaction.js +1 -0
- package/_esm/actions/solana/signTransaction.js.map +1 -1
- package/_esm/auth/hooks/axios/withAuth.js +3 -0
- package/_esm/auth/hooks/axios/withAuth.js.map +1 -1
- package/_esm/auth/utils/http.js +2 -1
- package/_esm/auth/utils/http.js.map +1 -1
- package/_esm/client/evm/evm.js +51 -1
- package/_esm/client/evm/evm.js.map +1 -1
- package/_esm/client/solana/solana.js +2 -2
- package/_esm/client/solana/solana.js.map +1 -1
- package/_esm/index.js +2 -1
- package/_esm/index.js.map +1 -1
- package/_esm/openapi-client/cdpApiClient.js +4 -0
- package/_esm/openapi-client/cdpApiClient.js.map +1 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +28 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +31 -0
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +153 -0
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
- package/_esm/openapi-client/generated/index.msw.js +1 -0
- package/_esm/openapi-client/generated/index.msw.js.map +1 -1
- package/_esm/openapi-client/generated/onramp/onramp.js +25 -0
- package/_esm/openapi-client/generated/onramp/onramp.js.map +1 -0
- package/_esm/openapi-client/generated/onramp/onramp.msw.js +90 -0
- package/_esm/openapi-client/generated/onramp/onramp.msw.js.map +1 -0
- package/_esm/openapi-client/index.js +1 -0
- package/_esm/openapi-client/index.js.map +1 -1
- package/_esm/spend-permissions/constants.js +713 -0
- package/_esm/spend-permissions/constants.js.map +1 -0
- package/_esm/spend-permissions/types.js +2 -0
- package/_esm/spend-permissions/types.js.map +1 -0
- package/_esm/version.js +1 -1
- package/_types/accounts/evm/networkCapabilities.d.ts +101 -0
- package/_types/accounts/evm/networkCapabilities.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts +1 -1
- package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toNetworkScopedEvmServerAccount.d.ts.map +1 -1
- package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
- package/_types/accounts/evm/types.d.ts +6 -0
- package/_types/accounts/evm/types.d.ts.map +1 -1
- package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
- package/_types/actions/evm/getUserOperation.d.ts.map +1 -1
- package/_types/actions/evm/spend-permissions/account.use.d.ts +15 -0
- package/_types/actions/evm/spend-permissions/account.use.d.ts.map +1 -0
- package/_types/actions/evm/spend-permissions/smartAccount.use.d.ts +15 -0
- package/_types/actions/evm/spend-permissions/smartAccount.use.d.ts.map +1 -0
- package/_types/actions/evm/spend-permissions/types.d.ts +13 -0
- package/_types/actions/evm/spend-permissions/types.d.ts.map +1 -0
- package/_types/actions/evm/types.d.ts +75 -0
- package/_types/actions/evm/types.d.ts.map +1 -1
- package/_types/actions/solana/sendTransaction.d.ts +8 -2
- package/_types/actions/solana/sendTransaction.d.ts.map +1 -1
- package/_types/actions/solana/signTransaction.d.ts +8 -2
- package/_types/actions/solana/signTransaction.d.ts.map +1 -1
- package/_types/actions/solana/types.d.ts +38 -3
- package/_types/actions/solana/types.d.ts.map +1 -1
- package/_types/auth/hooks/axios/withAuth.d.ts.map +1 -1
- package/_types/auth/utils/http.d.ts.map +1 -1
- package/_types/client/evm/evm.d.ts +19 -1
- package/_types/client/evm/evm.d.ts.map +1 -1
- package/_types/client/evm/evm.types.d.ts +49 -2
- package/_types/client/evm/evm.types.d.ts.map +1 -1
- package/_types/client/solana/solana.d.ts +5 -3
- package/_types/client/solana/solana.d.ts.map +1 -1
- package/_types/index.d.ts +3 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +269 -5
- package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +19 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts +7 -1
- package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/index.msw.d.ts +1 -0
- package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
- package/_types/openapi-client/generated/onramp/onramp.d.ts +28 -0
- package/_types/openapi-client/generated/onramp/onramp.d.ts.map +1 -0
- package/_types/openapi-client/generated/onramp/onramp.msw.d.ts +8 -0
- package/_types/openapi-client/generated/onramp/onramp.msw.d.ts.map +1 -0
- package/_types/openapi-client/index.d.ts +7 -0
- package/_types/openapi-client/index.d.ts.map +1 -1
- package/_types/spend-permissions/constants.d.ts +1357 -0
- package/_types/spend-permissions/constants.d.ts.map +1 -0
- package/_types/spend-permissions/types.d.ts +30 -0
- package/_types/spend-permissions/types.d.ts.map +1 -0
- package/_types/version.d.ts +1 -1
- package/accounts/evm/networkCapabilities.ts +101 -0
- package/accounts/evm/toEvmServerAccount.ts +15 -0
- package/accounts/evm/toEvmSmartAccount.ts +19 -4
- package/accounts/evm/toNetworkScopedEvmServerAccount.ts +15 -0
- package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +15 -0
- package/accounts/evm/types.ts +18 -0
- package/accounts/solana/toSolanaAccount.ts +17 -3
- package/actions/evm/getUserOperation.ts +1 -0
- package/actions/evm/spend-permissions/account.use.ts +48 -0
- package/actions/evm/spend-permissions/smartAccount.use.ts +49 -0
- package/actions/evm/spend-permissions/types.ts +13 -0
- package/actions/evm/types.ts +81 -0
- package/actions/solana/sendTransaction.ts +10 -2
- package/actions/solana/signTransaction.ts +10 -2
- package/actions/solana/types.ts +44 -2
- package/auth/hooks/axios/withAuth.ts +3 -0
- package/auth/utils/http.ts +2 -1
- package/client/evm/evm.ts +61 -1
- package/client/evm/evm.types.ts +55 -0
- package/client/solana/solana.ts +10 -5
- package/index.ts +6 -1
- package/openapi-client/cdpApiClient.ts +5 -0
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +300 -5
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +203 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +65 -0
- package/openapi-client/generated/index.msw.ts +1 -0
- package/openapi-client/generated/onramp/onramp.msw.ts +135 -0
- package/openapi-client/generated/onramp/onramp.ts +54 -0
- package/openapi-client/index.ts +1 -0
- package/package.json +2 -1
- package/spend-permissions/constants.ts +713 -0
- package/spend-permissions/types.ts +42 -0
- package/version.ts +1 -1
|
@@ -7,11 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type {
|
|
9
9
|
CreateEvmSmartAccountBody,
|
|
10
|
+
CreateSpendPermissionRequest,
|
|
10
11
|
EvmSmartAccount,
|
|
11
12
|
EvmUserOperation,
|
|
12
13
|
ListEvmSmartAccounts200,
|
|
13
14
|
ListEvmSmartAccountsParams,
|
|
15
|
+
ListSpendPermissions200,
|
|
16
|
+
ListSpendPermissionsParams,
|
|
14
17
|
PrepareUserOperationBody,
|
|
18
|
+
RevokeSpendPermissionRequest,
|
|
15
19
|
SendUserOperationBody,
|
|
16
20
|
UpdateEvmSmartAccountBody,
|
|
17
21
|
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
@@ -153,6 +157,58 @@ export const sendUserOperation = (
|
|
|
153
157
|
options,
|
|
154
158
|
);
|
|
155
159
|
};
|
|
160
|
+
/**
|
|
161
|
+
* Creates a spend permission for the given smart account address.
|
|
162
|
+
* @summary Create a spend permission
|
|
163
|
+
*/
|
|
164
|
+
export const createSpendPermission = (
|
|
165
|
+
address: string,
|
|
166
|
+
createSpendPermissionRequest: CreateSpendPermissionRequest,
|
|
167
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
168
|
+
) => {
|
|
169
|
+
return cdpApiClient<EvmUserOperation>(
|
|
170
|
+
{
|
|
171
|
+
url: `/v2/evm/smart-accounts/${address}/spend-permissions`,
|
|
172
|
+
method: "POST",
|
|
173
|
+
headers: { "Content-Type": "application/json" },
|
|
174
|
+
data: createSpendPermissionRequest,
|
|
175
|
+
},
|
|
176
|
+
options,
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Lists spend permission for the given smart account address.
|
|
181
|
+
* @summary List spend permissions
|
|
182
|
+
*/
|
|
183
|
+
export const listSpendPermissions = (
|
|
184
|
+
address: string,
|
|
185
|
+
params?: ListSpendPermissionsParams,
|
|
186
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
187
|
+
) => {
|
|
188
|
+
return cdpApiClient<ListSpendPermissions200>(
|
|
189
|
+
{ url: `/v2/evm/smart-accounts/${address}/spend-permissions/list`, method: "GET", params },
|
|
190
|
+
options,
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Revokes an existing spend permission.
|
|
195
|
+
* @summary Revoke a spend permission
|
|
196
|
+
*/
|
|
197
|
+
export const revokeSpendPermission = (
|
|
198
|
+
address: string,
|
|
199
|
+
revokeSpendPermissionRequest: RevokeSpendPermissionRequest,
|
|
200
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
201
|
+
) => {
|
|
202
|
+
return cdpApiClient<EvmUserOperation>(
|
|
203
|
+
{
|
|
204
|
+
url: `/v2/evm/smart-accounts/${address}/spend-permissions/revoke`,
|
|
205
|
+
method: "POST",
|
|
206
|
+
headers: { "Content-Type": "application/json" },
|
|
207
|
+
data: revokeSpendPermissionRequest,
|
|
208
|
+
},
|
|
209
|
+
options,
|
|
210
|
+
);
|
|
211
|
+
};
|
|
156
212
|
export type ListEvmSmartAccountsResult = NonNullable<
|
|
157
213
|
Awaited<ReturnType<typeof listEvmSmartAccounts>>
|
|
158
214
|
>;
|
|
@@ -171,3 +227,12 @@ export type PrepareUserOperationResult = NonNullable<
|
|
|
171
227
|
>;
|
|
172
228
|
export type GetUserOperationResult = NonNullable<Awaited<ReturnType<typeof getUserOperation>>>;
|
|
173
229
|
export type SendUserOperationResult = NonNullable<Awaited<ReturnType<typeof sendUserOperation>>>;
|
|
230
|
+
export type CreateSpendPermissionResult = NonNullable<
|
|
231
|
+
Awaited<ReturnType<typeof createSpendPermission>>
|
|
232
|
+
>;
|
|
233
|
+
export type ListSpendPermissionsResult = NonNullable<
|
|
234
|
+
Awaited<ReturnType<typeof listSpendPermissions>>
|
|
235
|
+
>;
|
|
236
|
+
export type RevokeSpendPermissionResult = NonNullable<
|
|
237
|
+
Awaited<ReturnType<typeof revokeSpendPermission>>
|
|
238
|
+
>;
|
|
@@ -3,6 +3,7 @@ export * from "./evm-smart-accounts/evm-smart-accounts.msw.js";
|
|
|
3
3
|
export * from "./evm-swaps/evm-swaps.msw.js";
|
|
4
4
|
export * from "./evm-token-balances/evm-token-balances.msw.js";
|
|
5
5
|
export * from "./faucets/faucets.msw.js";
|
|
6
|
+
export * from "./onramp/onramp.msw.js";
|
|
6
7
|
export * from "./payments-alpha/payments-alpha.msw.js";
|
|
7
8
|
export * from "./policy-engine/policy-engine.msw.js";
|
|
8
9
|
export * from "./solana-accounts/solana-accounts.msw.js";
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { faker } from "@faker-js/faker";
|
|
9
|
+
|
|
10
|
+
import { HttpResponse, delay, http } from "msw";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
OnrampOrderStatus,
|
|
14
|
+
OnrampPaymentLinkType,
|
|
15
|
+
OnrampPaymentMethodTypeId,
|
|
16
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
17
|
+
import type {
|
|
18
|
+
CreateOnrampOrder201,
|
|
19
|
+
GetOnrampOrderById200,
|
|
20
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
21
|
+
|
|
22
|
+
export const getCreateOnrampOrderResponseMock = (
|
|
23
|
+
overrideResponse: Partial<CreateOnrampOrder201> = {},
|
|
24
|
+
): CreateOnrampOrder201 => ({
|
|
25
|
+
order: {
|
|
26
|
+
orderId: faker.string.alpha(20),
|
|
27
|
+
paymentTotal: faker.string.alpha(20),
|
|
28
|
+
paymentSubtotal: faker.string.alpha(20),
|
|
29
|
+
paymentCurrency: faker.string.alpha(20),
|
|
30
|
+
paymentMethod: faker.helpers.arrayElement(Object.values(OnrampPaymentMethodTypeId)),
|
|
31
|
+
purchaseAmount: faker.string.alpha(20),
|
|
32
|
+
purchaseCurrency: faker.string.alpha(20),
|
|
33
|
+
fees: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
34
|
+
() => ({
|
|
35
|
+
type: faker.helpers.arrayElement(["FEE_TYPE_NETWORK", "FEE_TYPE_EXCHANGE"] as const),
|
|
36
|
+
amount: faker.string.alpha(20),
|
|
37
|
+
currency: faker.string.alpha(20),
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
|
+
exchangeRate: faker.string.alpha(20),
|
|
41
|
+
destinationAddress: faker.string.alpha(20),
|
|
42
|
+
destinationNetwork: faker.string.alpha(20),
|
|
43
|
+
status: faker.helpers.arrayElement(Object.values(OnrampOrderStatus)),
|
|
44
|
+
txHash: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
45
|
+
createdAt: faker.string.alpha(20),
|
|
46
|
+
updatedAt: faker.string.alpha(20),
|
|
47
|
+
},
|
|
48
|
+
paymentLink: faker.helpers.arrayElement([
|
|
49
|
+
{
|
|
50
|
+
url: faker.string.alpha(20),
|
|
51
|
+
paymentLinkType: faker.helpers.arrayElement(Object.values(OnrampPaymentLinkType)),
|
|
52
|
+
},
|
|
53
|
+
undefined,
|
|
54
|
+
]),
|
|
55
|
+
...overrideResponse,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const getGetOnrampOrderByIdResponseMock = (
|
|
59
|
+
overrideResponse: Partial<GetOnrampOrderById200> = {},
|
|
60
|
+
): GetOnrampOrderById200 => ({
|
|
61
|
+
order: {
|
|
62
|
+
orderId: faker.string.alpha(20),
|
|
63
|
+
paymentTotal: faker.string.alpha(20),
|
|
64
|
+
paymentSubtotal: faker.string.alpha(20),
|
|
65
|
+
paymentCurrency: faker.string.alpha(20),
|
|
66
|
+
paymentMethod: faker.helpers.arrayElement(Object.values(OnrampPaymentMethodTypeId)),
|
|
67
|
+
purchaseAmount: faker.string.alpha(20),
|
|
68
|
+
purchaseCurrency: faker.string.alpha(20),
|
|
69
|
+
fees: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
|
|
70
|
+
() => ({
|
|
71
|
+
type: faker.helpers.arrayElement(["FEE_TYPE_NETWORK", "FEE_TYPE_EXCHANGE"] as const),
|
|
72
|
+
amount: faker.string.alpha(20),
|
|
73
|
+
currency: faker.string.alpha(20),
|
|
74
|
+
}),
|
|
75
|
+
),
|
|
76
|
+
exchangeRate: faker.string.alpha(20),
|
|
77
|
+
destinationAddress: faker.string.alpha(20),
|
|
78
|
+
destinationNetwork: faker.string.alpha(20),
|
|
79
|
+
status: faker.helpers.arrayElement(Object.values(OnrampOrderStatus)),
|
|
80
|
+
txHash: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
|
|
81
|
+
createdAt: faker.string.alpha(20),
|
|
82
|
+
updatedAt: faker.string.alpha(20),
|
|
83
|
+
},
|
|
84
|
+
...overrideResponse,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const getCreateOnrampOrderMockHandler = (
|
|
88
|
+
overrideResponse?:
|
|
89
|
+
| CreateOnrampOrder201
|
|
90
|
+
| ((
|
|
91
|
+
info: Parameters<Parameters<typeof http.post>[1]>[0],
|
|
92
|
+
) => Promise<CreateOnrampOrder201> | CreateOnrampOrder201),
|
|
93
|
+
) => {
|
|
94
|
+
return http.post("*/v2/onramp/orders", async info => {
|
|
95
|
+
await delay(0);
|
|
96
|
+
|
|
97
|
+
return new HttpResponse(
|
|
98
|
+
JSON.stringify(
|
|
99
|
+
overrideResponse !== undefined
|
|
100
|
+
? typeof overrideResponse === "function"
|
|
101
|
+
? await overrideResponse(info)
|
|
102
|
+
: overrideResponse
|
|
103
|
+
: getCreateOnrampOrderResponseMock(),
|
|
104
|
+
),
|
|
105
|
+
{ status: 201, headers: { "Content-Type": "application/json" } },
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const getGetOnrampOrderByIdMockHandler = (
|
|
111
|
+
overrideResponse?:
|
|
112
|
+
| GetOnrampOrderById200
|
|
113
|
+
| ((
|
|
114
|
+
info: Parameters<Parameters<typeof http.get>[1]>[0],
|
|
115
|
+
) => Promise<GetOnrampOrderById200> | GetOnrampOrderById200),
|
|
116
|
+
) => {
|
|
117
|
+
return http.get("*/v2/onramp/orders/:orderId", async info => {
|
|
118
|
+
await delay(0);
|
|
119
|
+
|
|
120
|
+
return new HttpResponse(
|
|
121
|
+
JSON.stringify(
|
|
122
|
+
overrideResponse !== undefined
|
|
123
|
+
? typeof overrideResponse === "function"
|
|
124
|
+
? await overrideResponse(info)
|
|
125
|
+
: overrideResponse
|
|
126
|
+
: getGetOnrampOrderByIdResponseMock(),
|
|
127
|
+
),
|
|
128
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
export const getOnrampMock = () => [
|
|
133
|
+
getCreateOnrampOrderMockHandler(),
|
|
134
|
+
getGetOnrampOrderByIdMockHandler(),
|
|
135
|
+
];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v7.6.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Coinbase Developer Platform APIs
|
|
5
|
+
* The Coinbase Developer Platform APIs - leading the world's transition onchain.
|
|
6
|
+
* OpenAPI spec version: 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
import type {
|
|
9
|
+
CreateOnrampOrder201,
|
|
10
|
+
CreateOnrampOrderBody,
|
|
11
|
+
GetOnrampOrderById200,
|
|
12
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
13
|
+
|
|
14
|
+
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
15
|
+
|
|
16
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new Onramp order or get a quote for an Onramp order. Either `paymentAmount` or `purchaseAmount` must be provided.
|
|
20
|
+
|
|
21
|
+
This API currently only supports the payment method `GUEST_CHECKOUT_APPLE_PAY`, and the `paymentLink` returned will only work in iOS apps. We do not support web integration via iframes at this time.
|
|
22
|
+
|
|
23
|
+
For detailed integration instructions and to get access to this API, refer to the [Apple Pay Onramp API docs](https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/apple-pay-onramp-api).
|
|
24
|
+
* @summary Create an onramp order
|
|
25
|
+
*/
|
|
26
|
+
export const createOnrampOrder = (
|
|
27
|
+
createOnrampOrderBody: CreateOnrampOrderBody,
|
|
28
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
29
|
+
) => {
|
|
30
|
+
return cdpApiClient<CreateOnrampOrder201>(
|
|
31
|
+
{
|
|
32
|
+
url: `/v2/onramp/orders`,
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: { "Content-Type": "application/json" },
|
|
35
|
+
data: createOnrampOrderBody,
|
|
36
|
+
},
|
|
37
|
+
options,
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Get an onramp order by ID.
|
|
42
|
+
* @summary Get an onramp order by ID
|
|
43
|
+
*/
|
|
44
|
+
export const getOnrampOrderById = (
|
|
45
|
+
orderId: string,
|
|
46
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
47
|
+
) => {
|
|
48
|
+
return cdpApiClient<GetOnrampOrderById200>(
|
|
49
|
+
{ url: `/v2/onramp/orders/${orderId}`, method: "GET" },
|
|
50
|
+
options,
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
export type CreateOnrampOrderResult = NonNullable<Awaited<ReturnType<typeof createOnrampOrder>>>;
|
|
54
|
+
export type GetOnrampOrderByIdResult = NonNullable<Awaited<ReturnType<typeof getOnrampOrderById>>>;
|
package/openapi-client/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./generated/solana-token-balances/solana-token-balances.js";
|
|
|
8
8
|
export * from "./generated/faucets/faucets.js";
|
|
9
9
|
export * from "./generated/policy-engine/policy-engine.js";
|
|
10
10
|
export * from "./generated/payments-alpha/payments-alpha.js";
|
|
11
|
+
export * from "./generated/onramp/onramp.js";
|
|
11
12
|
|
|
12
13
|
import { configure } from "./cdpApiClient.js";
|
|
13
14
|
import * as evm from "./generated/evm-accounts/evm-accounts.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"description": "SDK for interacting with the Coinbase Developer Platform Wallet API",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@solana/web3.js": "^1.98.1",
|
|
23
23
|
"abitype": "1.0.6",
|
|
24
24
|
"axios": "^1.8.2",
|
|
25
|
+
"axios-retry": "^4.5.0",
|
|
25
26
|
"jose": "^6.0.8",
|
|
26
27
|
"md5": "^2.3.0",
|
|
27
28
|
"uncrypto": "^0.1.3",
|