@coinbase/cdp-sdk 1.29.0 → 1.30.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 +10 -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/generated/coinbaseDeveloperPlatformAPIs.schemas.js +41 -3
- package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +14 -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 +72 -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 +2 -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/generated/x402-facilitator/x402-facilitator.js +15 -0
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -0
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js +69 -0
- package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js.map +1 -0
- package/_cjs/openapi-client/index.js +2 -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/generated/coinbaseDeveloperPlatformAPIs.schemas.js +39 -1
- package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
- package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +12 -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 +69 -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 +2 -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/generated/x402-facilitator/x402-facilitator.js +11 -0
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -0
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js +63 -0
- package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js.map +1 -0
- package/_esm/openapi-client/index.js +2 -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 +29 -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/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +333 -1
- 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 +7 -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 +2 -0
- 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 +2 -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/generated/x402-facilitator/x402-facilitator.d.ts +20 -0
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts.map +1 -0
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.msw.d.ts +6 -0
- package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.msw.d.ts.map +1 -0
- package/_types/openapi-client/index.d.ts +4 -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 +31 -0
- package/client/solana/solana.ts +10 -5
- package/index.ts +6 -1
- package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +375 -1
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +85 -0
- package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +23 -0
- package/openapi-client/generated/index.msw.ts +2 -0
- package/openapi-client/generated/onramp/onramp.msw.ts +135 -0
- package/openapi-client/generated/onramp/onramp.ts +54 -0
- package/openapi-client/generated/x402-facilitator/x402-facilitator.msw.ts +85 -0
- package/openapi-client/generated/x402-facilitator/x402-facilitator.ts +34 -0
- package/openapi-client/index.ts +2 -0
- package/package.json +1 -1
- package/spend-permissions/constants.ts +713 -0
- package/spend-permissions/types.ts +42 -0
- package/version.ts +1 -1
|
@@ -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: {},
|
|
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: {},
|
|
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 payment link returned will only work in native apps. We do not support web integration via iFrames.
|
|
22
|
+
|
|
23
|
+
Please refer to the [Onramp docs](https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/onramp-overview) for detailed integration instructions.
|
|
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>>>;
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { X402Version } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
13
|
+
import type { X402DiscoveryResourcesResponse } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
14
|
+
|
|
15
|
+
export const getListX402DiscoveryResourcesResponseMock = (
|
|
16
|
+
overrideResponse: Partial<X402DiscoveryResourcesResponse> = {},
|
|
17
|
+
): X402DiscoveryResourcesResponse => ({
|
|
18
|
+
x402Version: faker.helpers.arrayElement(Object.values(X402Version)),
|
|
19
|
+
items: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
|
|
20
|
+
resource: faker.string.alpha(20),
|
|
21
|
+
type: faker.helpers.arrayElement(["http"] as const),
|
|
22
|
+
x402Version: faker.helpers.arrayElement(Object.values(X402Version)),
|
|
23
|
+
accepts: faker.helpers.arrayElement([
|
|
24
|
+
Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
|
|
25
|
+
scheme: faker.helpers.arrayElement(["exact"] as const),
|
|
26
|
+
network: faker.helpers.arrayElement(["base-sepolia", "base"] as const),
|
|
27
|
+
maxAmountRequired: faker.string.alpha(20),
|
|
28
|
+
resource: faker.string.alpha(20),
|
|
29
|
+
description: faker.string.alpha(20),
|
|
30
|
+
mimeType: faker.string.alpha(20),
|
|
31
|
+
outputSchema: faker.helpers.arrayElement([{}, undefined]),
|
|
32
|
+
payTo: faker.helpers.fromRegExp(
|
|
33
|
+
"^0x[a-fA-F0-9]{40}|[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$",
|
|
34
|
+
),
|
|
35
|
+
maxTimeoutSeconds: faker.number.int({ min: undefined, max: undefined }),
|
|
36
|
+
asset: faker.helpers.fromRegExp(
|
|
37
|
+
"^0x[a-fA-F0-9]{40}|[A-Za-z0-9][A-Za-z0-9-]{0,34}[A-Za-z0-9]$",
|
|
38
|
+
),
|
|
39
|
+
extra: faker.helpers.arrayElement([{}, undefined]),
|
|
40
|
+
})),
|
|
41
|
+
undefined,
|
|
42
|
+
]),
|
|
43
|
+
lastUpdated: `${faker.date.past().toISOString().split(".")[0]}Z`,
|
|
44
|
+
metadata: faker.helpers.arrayElement([{}, undefined]),
|
|
45
|
+
})),
|
|
46
|
+
pagination: {
|
|
47
|
+
limit: faker.helpers.arrayElement([
|
|
48
|
+
faker.number.int({ min: undefined, max: undefined }),
|
|
49
|
+
undefined,
|
|
50
|
+
]),
|
|
51
|
+
offset: faker.helpers.arrayElement([
|
|
52
|
+
faker.number.int({ min: undefined, max: undefined }),
|
|
53
|
+
undefined,
|
|
54
|
+
]),
|
|
55
|
+
total: faker.helpers.arrayElement([
|
|
56
|
+
faker.number.int({ min: undefined, max: undefined }),
|
|
57
|
+
undefined,
|
|
58
|
+
]),
|
|
59
|
+
},
|
|
60
|
+
...overrideResponse,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const getListX402DiscoveryResourcesMockHandler = (
|
|
64
|
+
overrideResponse?:
|
|
65
|
+
| X402DiscoveryResourcesResponse
|
|
66
|
+
| ((
|
|
67
|
+
info: Parameters<Parameters<typeof http.get>[1]>[0],
|
|
68
|
+
) => Promise<X402DiscoveryResourcesResponse> | X402DiscoveryResourcesResponse),
|
|
69
|
+
) => {
|
|
70
|
+
return http.get("*/v2/x402/discovery/resources", async info => {
|
|
71
|
+
await delay(0);
|
|
72
|
+
|
|
73
|
+
return new HttpResponse(
|
|
74
|
+
JSON.stringify(
|
|
75
|
+
overrideResponse !== undefined
|
|
76
|
+
? typeof overrideResponse === "function"
|
|
77
|
+
? await overrideResponse(info)
|
|
78
|
+
: overrideResponse
|
|
79
|
+
: getListX402DiscoveryResourcesResponseMock(),
|
|
80
|
+
),
|
|
81
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
export const getX402FacilitatorMock = () => [getListX402DiscoveryResourcesMockHandler()];
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
ListX402DiscoveryResourcesParams,
|
|
10
|
+
X402DiscoveryResourcesResponse,
|
|
11
|
+
} from "../coinbaseDeveloperPlatformAPIs.schemas.js";
|
|
12
|
+
|
|
13
|
+
import { cdpApiClient } from "../../cdpApiClient.js";
|
|
14
|
+
|
|
15
|
+
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Lists all active discovered x402 resources.
|
|
19
|
+
This endpoint returns resources that have been discovered and cached by the x402 facilitator, including their payment requirements and metadata.
|
|
20
|
+
The response is paginated, and by default, returns 100 items per page.
|
|
21
|
+
* @summary List discovered x402 resources
|
|
22
|
+
*/
|
|
23
|
+
export const listX402DiscoveryResources = (
|
|
24
|
+
params?: ListX402DiscoveryResourcesParams,
|
|
25
|
+
options?: SecondParameter<typeof cdpApiClient>,
|
|
26
|
+
) => {
|
|
27
|
+
return cdpApiClient<X402DiscoveryResourcesResponse>(
|
|
28
|
+
{ url: `/v2/x402/discovery/resources`, method: "GET", params },
|
|
29
|
+
options,
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
export type ListX402DiscoveryResourcesResult = NonNullable<
|
|
33
|
+
Awaited<ReturnType<typeof listX402DiscoveryResources>>
|
|
34
|
+
>;
|
package/openapi-client/index.ts
CHANGED
|
@@ -8,6 +8,8 @@ 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/x402-facilitator/x402-facilitator.js";
|
|
12
|
+
export * from "./generated/onramp/onramp.js";
|
|
11
13
|
|
|
12
14
|
import { configure } from "./cdpApiClient.js";
|
|
13
15
|
import * as evm from "./generated/evm-accounts/evm-accounts.js";
|