@daimo/pay-common 1.15.0 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/daimoPay.d.ts +32 -32
- package/dist/daimoPay.js +9 -10
- package/dist/daimoPay.js.map +1 -1
- package/dist/primitiveTypes.d.ts +2 -0
- package/dist/primitiveTypes.js +2 -1
- package/dist/primitiveTypes.js.map +1 -1
- package/package.json +2 -2
- package/src/daimoPay.ts +18 -39
- package/src/primitiveTypes.ts +4 -0
package/dist/daimoPay.d.ts
CHANGED
|
@@ -93,6 +93,16 @@ export declare const zDaimoPayOrderMetadata: z.ZodObject<{
|
|
|
93
93
|
}>, "many">>;
|
|
94
94
|
evmChains: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
95
95
|
paymentOptions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
96
|
+
passthroughTokens: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
97
|
+
chain: z.ZodNumber;
|
|
98
|
+
address: z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
chain: number;
|
|
101
|
+
address: `0x${string}`;
|
|
102
|
+
}, {
|
|
103
|
+
chain: number;
|
|
104
|
+
address: string;
|
|
105
|
+
}>, "many">>;
|
|
96
106
|
}, "strip", z.ZodTypeAny, {
|
|
97
107
|
preferredChains?: number[] | undefined;
|
|
98
108
|
preferredTokens?: {
|
|
@@ -101,6 +111,10 @@ export declare const zDaimoPayOrderMetadata: z.ZodObject<{
|
|
|
101
111
|
}[] | undefined;
|
|
102
112
|
evmChains?: number[] | undefined;
|
|
103
113
|
paymentOptions?: string[] | undefined;
|
|
114
|
+
passthroughTokens?: {
|
|
115
|
+
chain: number;
|
|
116
|
+
address: `0x${string}`;
|
|
117
|
+
}[] | undefined;
|
|
104
118
|
}, {
|
|
105
119
|
preferredChains?: number[] | undefined;
|
|
106
120
|
preferredTokens?: {
|
|
@@ -109,6 +123,10 @@ export declare const zDaimoPayOrderMetadata: z.ZodObject<{
|
|
|
109
123
|
}[] | undefined;
|
|
110
124
|
evmChains?: number[] | undefined;
|
|
111
125
|
paymentOptions?: string[] | undefined;
|
|
126
|
+
passthroughTokens?: {
|
|
127
|
+
chain: number;
|
|
128
|
+
address: string;
|
|
129
|
+
}[] | undefined;
|
|
112
130
|
}>>;
|
|
113
131
|
}, "strip", z.ZodTypeAny, {
|
|
114
132
|
intent: string;
|
|
@@ -131,6 +149,10 @@ export declare const zDaimoPayOrderMetadata: z.ZodObject<{
|
|
|
131
149
|
}[] | undefined;
|
|
132
150
|
evmChains?: number[] | undefined;
|
|
133
151
|
paymentOptions?: string[] | undefined;
|
|
152
|
+
passthroughTokens?: {
|
|
153
|
+
chain: number;
|
|
154
|
+
address: `0x${string}`;
|
|
155
|
+
}[] | undefined;
|
|
134
156
|
} | undefined;
|
|
135
157
|
}, {
|
|
136
158
|
intent: string;
|
|
@@ -153,6 +175,10 @@ export declare const zDaimoPayOrderMetadata: z.ZodObject<{
|
|
|
153
175
|
}[] | undefined;
|
|
154
176
|
evmChains?: number[] | undefined;
|
|
155
177
|
paymentOptions?: string[] | undefined;
|
|
178
|
+
passthroughTokens?: {
|
|
179
|
+
chain: number;
|
|
180
|
+
address: string;
|
|
181
|
+
}[] | undefined;
|
|
156
182
|
} | undefined;
|
|
157
183
|
}>;
|
|
158
184
|
export type DaimoPayOrderMetadata = z.infer<typeof zDaimoPayOrderMetadata>;
|
|
@@ -208,6 +234,7 @@ export type DaimoPayHydratedOrder = {
|
|
|
208
234
|
destStatus: DaimoPayOrderStatusDest;
|
|
209
235
|
destFastFinishTxHash: Hex | null;
|
|
210
236
|
destClaimTxHash: Hex | null;
|
|
237
|
+
passedToAddress: Address | null;
|
|
211
238
|
redirectUri: string | null;
|
|
212
239
|
orgId: string | null;
|
|
213
240
|
sourceInitiateUpdatedAt: number | null;
|
|
@@ -267,11 +294,15 @@ export declare function getOrderSourceChainId(order: DaimoPayHydratedOrder): num
|
|
|
267
294
|
export declare function getOrderDestChainId(order: DaimoPayOrder | DaimoPayHydratedOrderWithoutIntentAddr): number;
|
|
268
295
|
export declare function getDaimoPayOrderView(order: DaimoPayOrder): DaimoPayOrderView;
|
|
269
296
|
export type WalletPaymentOption = {
|
|
297
|
+
/** The user's balance of this token. */
|
|
270
298
|
balance: DaimoPayTokenAmount;
|
|
271
299
|
required: DaimoPayTokenAmount;
|
|
272
300
|
minimumRequired: DaimoPayTokenAmount;
|
|
273
301
|
fees: DaimoPayTokenAmount;
|
|
302
|
+
/** If present, the option is disabled. */
|
|
274
303
|
disabledReason?: string;
|
|
304
|
+
/** If present, send directly to passthroughAddress, no swap or bridge. */
|
|
305
|
+
passthroughAddress?: Address;
|
|
275
306
|
};
|
|
276
307
|
export type ExternalPaymentOptionMetadata = {
|
|
277
308
|
id: ExternalPaymentOptions;
|
|
@@ -302,6 +333,7 @@ export declare enum ExternalPaymentOptions {
|
|
|
302
333
|
export type ExternalPaymentOptionsString = `${ExternalPaymentOptions}`;
|
|
303
334
|
export declare enum UniquePaymentOptions {
|
|
304
335
|
Wallets = "Wallets",
|
|
336
|
+
AllExchanges = "AllExchanges",
|
|
305
337
|
Coinbase = "Coinbase",
|
|
306
338
|
Binance = "Binance",
|
|
307
339
|
Lemon = "Lemon",
|
|
@@ -387,8 +419,6 @@ export declare function readDaimoPayOrderID(id: string): bigint;
|
|
|
387
419
|
* Write a bigint into a base58-encoded id.
|
|
388
420
|
*/
|
|
389
421
|
export declare function writeDaimoPayOrderID(id: bigint): string;
|
|
390
|
-
export declare const zUUID: z.ZodString;
|
|
391
|
-
export type UUID = z.infer<typeof zUUID>;
|
|
392
422
|
export declare enum DaimoPayEventType {
|
|
393
423
|
PaymentStarted = "payment_started",
|
|
394
424
|
PaymentCompleted = "payment_completed",
|
|
@@ -431,34 +461,4 @@ export type PaymentRefundedEvent = {
|
|
|
431
461
|
payment: DaimoPayOrderView;
|
|
432
462
|
};
|
|
433
463
|
export type DaimoPayEvent = PaymentStartedEvent | PaymentCompletedEvent | PaymentBouncedEvent | PaymentRefundedEvent;
|
|
434
|
-
export interface WebhookEndpoint {
|
|
435
|
-
id: UUID;
|
|
436
|
-
orgId: UUID;
|
|
437
|
-
url: string;
|
|
438
|
-
token: string;
|
|
439
|
-
createdAt: Date;
|
|
440
|
-
deletedAt: Date | null;
|
|
441
|
-
}
|
|
442
|
-
export declare enum WebhookEventStatus {
|
|
443
|
-
PENDING = "pending",// waiting to be delivered
|
|
444
|
-
RETRYING = "retrying",// currently in exponential backoff queue
|
|
445
|
-
SUCCESSFUL = "successful",// successfully delivered
|
|
446
|
-
FAILED = "failed"
|
|
447
|
-
}
|
|
448
|
-
export interface WebhookEvent {
|
|
449
|
-
id: UUID;
|
|
450
|
-
endpoint: WebhookEndpoint;
|
|
451
|
-
isTestEvent: boolean;
|
|
452
|
-
body: DaimoPayEvent;
|
|
453
|
-
status: WebhookEventStatus;
|
|
454
|
-
deliveries: WebhookDelivery[];
|
|
455
|
-
createdAt: Date;
|
|
456
|
-
}
|
|
457
|
-
export interface WebhookDelivery {
|
|
458
|
-
id: UUID;
|
|
459
|
-
eventId: UUID;
|
|
460
|
-
httpStatus: number | null;
|
|
461
|
-
body: string | null;
|
|
462
|
-
createdAt: Date;
|
|
463
|
-
}
|
|
464
464
|
export {};
|
package/dist/daimoPay.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
8
|
+
exports.DaimoPayEventType = exports.emptyOnChainCall = exports.DepositAddressPaymentOptions = exports.UniquePaymentOptions = exports.ExternalPaymentOptions = exports.zDaimoPayUserMetadata = exports.zDaimoPayOrderMetadata = exports.zBridgeTokenOutOptions = exports.DaimoPayIntentStatus = exports.DaimoPayOrderMode = exports.DaimoPayOrderStatusDest = exports.DaimoPayOrderStatusSource = void 0;
|
|
9
9
|
exports.isHydrated = isHydrated;
|
|
10
10
|
exports.getOrderSourceChainId = getOrderSourceChainId;
|
|
11
11
|
exports.getOrderDestChainId = getOrderDestChainId;
|
|
@@ -106,6 +106,13 @@ exports.zDaimoPayOrderMetadata = zod_1.default.object({
|
|
|
106
106
|
.array(zod_1.default.string())
|
|
107
107
|
.optional()
|
|
108
108
|
.describe("Payment options like Coinbase, Binance, etc. Defaults to all available options."),
|
|
109
|
+
passthroughTokens: zod_1.default
|
|
110
|
+
.array(zod_1.default.object({
|
|
111
|
+
chain: zod_1.default.number(),
|
|
112
|
+
address: primitiveTypes_1.zAddress.transform((a) => (0, viem_1.getAddress)(a)),
|
|
113
|
+
}))
|
|
114
|
+
.optional()
|
|
115
|
+
.describe("Pass-through tokens. If the user pays via these tokens, they're sent directly to the destination address without swapping or bridging."),
|
|
109
116
|
})
|
|
110
117
|
.optional()
|
|
111
118
|
.describe(""),
|
|
@@ -192,6 +199,7 @@ var ExternalPaymentOptions;
|
|
|
192
199
|
var UniquePaymentOptions;
|
|
193
200
|
(function (UniquePaymentOptions) {
|
|
194
201
|
UniquePaymentOptions["Wallets"] = "Wallets";
|
|
202
|
+
UniquePaymentOptions["AllExchanges"] = "AllExchanges";
|
|
195
203
|
UniquePaymentOptions["Coinbase"] = "Coinbase";
|
|
196
204
|
UniquePaymentOptions["Binance"] = "Binance";
|
|
197
205
|
UniquePaymentOptions["Lemon"] = "Lemon";
|
|
@@ -244,7 +252,6 @@ function readDaimoPayOrderID(id) {
|
|
|
244
252
|
function writeDaimoPayOrderID(id) {
|
|
245
253
|
return base_1.base58.encode((0, viem_1.numberToBytes)(id));
|
|
246
254
|
}
|
|
247
|
-
exports.zUUID = zod_1.default.string().uuid();
|
|
248
255
|
var DaimoPayEventType;
|
|
249
256
|
(function (DaimoPayEventType) {
|
|
250
257
|
DaimoPayEventType["PaymentStarted"] = "payment_started";
|
|
@@ -252,12 +259,4 @@ var DaimoPayEventType;
|
|
|
252
259
|
DaimoPayEventType["PaymentBounced"] = "payment_bounced";
|
|
253
260
|
DaimoPayEventType["PaymentRefunded"] = "payment_refunded";
|
|
254
261
|
})(DaimoPayEventType || (exports.DaimoPayEventType = DaimoPayEventType = {}));
|
|
255
|
-
// Lifecycle: Pending (just created) -> (if failing) Retrying (exponential backoff) -> Successful or Failed
|
|
256
|
-
var WebhookEventStatus;
|
|
257
|
-
(function (WebhookEventStatus) {
|
|
258
|
-
WebhookEventStatus["PENDING"] = "pending";
|
|
259
|
-
WebhookEventStatus["RETRYING"] = "retrying";
|
|
260
|
-
WebhookEventStatus["SUCCESSFUL"] = "successful";
|
|
261
|
-
WebhookEventStatus["FAILED"] = "failed";
|
|
262
|
-
})(WebhookEventStatus || (exports.WebhookEventStatus = WebhookEventStatus = {}));
|
|
263
262
|
//# sourceMappingURL=daimoPay.js.map
|
package/dist/daimoPay.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daimoPay.js","sourceRoot":"","sources":["../src/daimoPay.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,wEAAwE;;;;;;
|
|
1
|
+
{"version":3,"file":"daimoPay.js","sourceRoot":"","sources":["../src/daimoPay.ts"],"names":[],"mappings":";AAAA,yEAAyE;AACzE,wEAAwE;;;;;;AA4PxE,gCAIC;AAgCD,sDAOC;AAED,kDAIC;AAED,oDAkDC;AAwJD,kDAEC;AAKD,oDAEC;AAhgBD,sCAAqC;AACrC,+BAQc;AACd,8CAAoB;AAGpB,qCAAyC;AACzC,qDAK0B;AAE1B,+GAA+G;AAC/G,IAAY,yBAMX;AAND,WAAY,yBAAyB;IACnC,gEAAmC,CAAA;IACnC,sEAAyC,CAAA;IACzC,gEAAmC,CAAA;IACnC,0CAA0C;IAC1C,oDAAuB,CAAA;AACzB,CAAC,EANW,yBAAyB,yCAAzB,yBAAyB,QA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,CAAA;IACnB,mDAAmB,CAAA;IAEnB,kBAAkB;IAClB,mDAAmB,CAAA;IACnB,kBAAkB;IAClB,2CAAW,CAAA;IACX,kBAAkB;IAClB,iDAAiB,CAAA;IACjB,kBAAkB;IAClB,6CAAa,CAAA;IACb,kBAAkB;IAClB,qDAAqB,CAAA;IACrB,kBAAkB;IAClB,+CAAe,CAAA;IACf,kBAAkB;IAClB,6CAAa,CAAA;AACf,CAAC,EAtBW,4BAA4B,4CAA5B,4BAA4B,QAsBvC;AA4CY,QAAA,gBAAgB,GAAgB;IAC3C,EAAE,EAAE,kBAAW;IACf,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,EAAE;CACV,CAAC;AAEF,wBAAwB;AACxB,MAAM,gBAAgB,GAAG,aAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAIrE;;GAEG;AACH,SAAgB,mBAAmB,CAAC,EAAU;IAC5C,OAAO,IAAA,oBAAa,EAAC,aAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,EAAU;IAC7C,OAAO,aAAM,CAAC,MAAM,CAAC,IAAA,oBAAa,EAAC,EAAE,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,uDAAkC,CAAA;IAClC,2DAAsC,CAAA;IACtC,uDAAkC,CAAA;IAClC,yDAAoC,CAAA;AACtC,CAAC,EALW,iBAAiB,iCAAjB,iBAAiB,QAK5B"}
|
package/dist/primitiveTypes.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const zBigIntStr: z.ZodEffects<z.ZodString, `${bigint}`, string>;
|
|
3
3
|
export type BigIntStr = `${bigint}`;
|
|
4
|
+
export declare const zUUID: z.ZodString;
|
|
5
|
+
export type UUID = z.infer<typeof zUUID>;
|
|
4
6
|
export declare const zAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
|
|
5
7
|
export declare const zHex: z.ZodEffects<z.ZodString, `0x${string}`, string>;
|
|
6
8
|
export declare const zSolanaPublicKey: z.ZodString;
|
package/dist/primitiveTypes.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.zSolanaPublicKey = exports.zHex = exports.zAddress = exports.zBigIntStr = void 0;
|
|
3
|
+
exports.zSolanaPublicKey = exports.zHex = exports.zAddress = exports.zUUID = exports.zBigIntStr = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
exports.zBigIntStr = zod_1.z
|
|
6
6
|
.string()
|
|
7
7
|
.regex(/^[0-9]+$/i)
|
|
8
8
|
.refine((s) => true);
|
|
9
|
+
exports.zUUID = zod_1.z.string().uuid();
|
|
9
10
|
exports.zAddress = zod_1.z
|
|
10
11
|
.string()
|
|
11
12
|
.regex(/^0x[0-9a-f]{40}$/i)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primitiveTypes.js","sourceRoot":"","sources":["../src/primitiveTypes.ts"],"names":[],"mappings":";;;AACA,6BAAwB;AAEX,QAAA,UAAU,GAAG,OAAC;KACxB,MAAM,EAAE;KACR,KAAK,CAAC,WAAW,CAAC;KAClB,MAAM,CAAC,CAAC,CAAC,EAAkB,EAAE,CAAC,IAAI,CAAC,CAAC;AAI1B,QAAA,QAAQ,GAAG,OAAC;KACtB,MAAM,EAAE;KACR,KAAK,CAAC,mBAAmB,CAAC;KAC1B,MAAM,CAAC,CAAC,CAAC,EAAgB,EAAE,CAAC,IAAI,CAAC,CAAC;AAExB,QAAA,IAAI,GAAG,OAAC;KAClB,MAAM,EAAE;KACR,KAAK,CAAC,gBAAgB,CAAC;KACvB,MAAM,CAAC,CAAC,CAAC,EAAY,EAAE,CAAC,IAAI,CAAC,CAAC;AAEpB,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"primitiveTypes.js","sourceRoot":"","sources":["../src/primitiveTypes.ts"],"names":[],"mappings":";;;AACA,6BAAwB;AAEX,QAAA,UAAU,GAAG,OAAC;KACxB,MAAM,EAAE;KACR,KAAK,CAAC,WAAW,CAAC;KAClB,MAAM,CAAC,CAAC,CAAC,EAAkB,EAAE,CAAC,IAAI,CAAC,CAAC;AAI1B,QAAA,KAAK,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;AAI1B,QAAA,QAAQ,GAAG,OAAC;KACtB,MAAM,EAAE;KACR,KAAK,CAAC,mBAAmB,CAAC;KAC1B,MAAM,CAAC,CAAC,CAAC,EAAgB,EAAE,CAAC,IAAI,CAAC,CAAC;AAExB,QAAA,IAAI,GAAG,OAAC;KAClB,MAAM,EAAE;KACR,KAAK,CAAC,gBAAgB,CAAC;KACvB,MAAM,CAAC,CAAC,CAAC,EAAY,EAAE,CAAC,IAAI,CAAC,CAAC;AAEpB,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daimo/pay-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "Daimo Pay shared types and utilities",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"eslint": "^8.56.0",
|
|
21
21
|
"tape": "^5.6.3",
|
|
22
22
|
"ts-node": "^10.9.2",
|
|
23
|
-
"typescript": "5.
|
|
23
|
+
"typescript": "5.9.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@scure/base": "^1.2.4",
|
package/src/daimoPay.ts
CHANGED
|
@@ -134,6 +134,17 @@ export const zDaimoPayOrderMetadata = z.object({
|
|
|
134
134
|
.describe(
|
|
135
135
|
"Payment options like Coinbase, Binance, etc. Defaults to all available options.",
|
|
136
136
|
),
|
|
137
|
+
passthroughTokens: z
|
|
138
|
+
.array(
|
|
139
|
+
z.object({
|
|
140
|
+
chain: z.number(),
|
|
141
|
+
address: zAddress.transform((a) => getAddress(a)),
|
|
142
|
+
}),
|
|
143
|
+
)
|
|
144
|
+
.optional()
|
|
145
|
+
.describe(
|
|
146
|
+
"Pass-through tokens. If the user pays via these tokens, they're sent directly to the destination address without swapping or bridging.",
|
|
147
|
+
),
|
|
137
148
|
})
|
|
138
149
|
.optional()
|
|
139
150
|
.describe(""),
|
|
@@ -205,6 +216,7 @@ export type DaimoPayHydratedOrder = {
|
|
|
205
216
|
destStatus: DaimoPayOrderStatusDest;
|
|
206
217
|
destFastFinishTxHash: Hex | null;
|
|
207
218
|
destClaimTxHash: Hex | null;
|
|
219
|
+
passedToAddress: Address | null;
|
|
208
220
|
redirectUri: string | null;
|
|
209
221
|
orgId: string | null;
|
|
210
222
|
sourceInitiateUpdatedAt: number | null;
|
|
@@ -343,6 +355,7 @@ export function getDaimoPayOrderView(order: DaimoPayOrder): DaimoPayOrderView {
|
|
|
343
355
|
}
|
|
344
356
|
|
|
345
357
|
export type WalletPaymentOption = {
|
|
358
|
+
/** The user's balance of this token. */
|
|
346
359
|
balance: DaimoPayTokenAmount;
|
|
347
360
|
|
|
348
361
|
// TODO: deprecate, replace with requiredUsd / minRequiredUsd / feesUsd
|
|
@@ -351,7 +364,11 @@ export type WalletPaymentOption = {
|
|
|
351
364
|
minimumRequired: DaimoPayTokenAmount;
|
|
352
365
|
fees: DaimoPayTokenAmount;
|
|
353
366
|
|
|
367
|
+
/** If present, the option is disabled. */
|
|
354
368
|
disabledReason?: string;
|
|
369
|
+
|
|
370
|
+
/** If present, send directly to passthroughAddress, no swap or bridge. */
|
|
371
|
+
passthroughAddress?: Address;
|
|
355
372
|
};
|
|
356
373
|
|
|
357
374
|
export type ExternalPaymentOptionMetadata = {
|
|
@@ -388,6 +405,7 @@ export type ExternalPaymentOptionsString = `${ExternalPaymentOptions}`;
|
|
|
388
405
|
|
|
389
406
|
export enum UniquePaymentOptions {
|
|
390
407
|
Wallets = "Wallets",
|
|
408
|
+
AllExchanges = "AllExchanges",
|
|
391
409
|
Coinbase = "Coinbase",
|
|
392
410
|
Binance = "Binance",
|
|
393
411
|
Lemon = "Lemon",
|
|
@@ -497,10 +515,6 @@ export function writeDaimoPayOrderID(id: bigint): string {
|
|
|
497
515
|
return base58.encode(numberToBytes(id));
|
|
498
516
|
}
|
|
499
517
|
|
|
500
|
-
export const zUUID = z.string().uuid();
|
|
501
|
-
|
|
502
|
-
export type UUID = z.infer<typeof zUUID>;
|
|
503
|
-
|
|
504
518
|
export enum DaimoPayEventType {
|
|
505
519
|
PaymentStarted = "payment_started",
|
|
506
520
|
PaymentCompleted = "payment_completed",
|
|
@@ -552,38 +566,3 @@ export type DaimoPayEvent =
|
|
|
552
566
|
| PaymentCompletedEvent
|
|
553
567
|
| PaymentBouncedEvent
|
|
554
568
|
| PaymentRefundedEvent;
|
|
555
|
-
|
|
556
|
-
export interface WebhookEndpoint {
|
|
557
|
-
id: UUID;
|
|
558
|
-
orgId: UUID;
|
|
559
|
-
url: string;
|
|
560
|
-
token: string;
|
|
561
|
-
createdAt: Date;
|
|
562
|
-
deletedAt: Date | null;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
// Lifecycle: Pending (just created) -> (if failing) Retrying (exponential backoff) -> Successful or Failed
|
|
566
|
-
export enum WebhookEventStatus {
|
|
567
|
-
PENDING = "pending", // waiting to be delivered
|
|
568
|
-
RETRYING = "retrying", // currently in exponential backoff queue
|
|
569
|
-
SUCCESSFUL = "successful", // successfully delivered
|
|
570
|
-
FAILED = "failed", // gave up after retrying
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
export interface WebhookEvent {
|
|
574
|
-
id: UUID;
|
|
575
|
-
endpoint: WebhookEndpoint;
|
|
576
|
-
isTestEvent: boolean;
|
|
577
|
-
body: DaimoPayEvent;
|
|
578
|
-
status: WebhookEventStatus;
|
|
579
|
-
deliveries: WebhookDelivery[];
|
|
580
|
-
createdAt: Date;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
export interface WebhookDelivery {
|
|
584
|
-
id: UUID;
|
|
585
|
-
eventId: UUID;
|
|
586
|
-
httpStatus: number | null;
|
|
587
|
-
body: string | null;
|
|
588
|
-
createdAt: Date;
|
|
589
|
-
}
|
package/src/primitiveTypes.ts
CHANGED