odin-connect 1.3.1 → 1.3.3
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/index.d.ts +406 -10
- package/dist/index.js +2 -2
- package/package.json +20 -4
- package/readme.md +7 -0
- package/.github/workflows/pr.yml +0 -24
- package/demo/README.md +0 -69
- package/demo/eslint.config.js +0 -23
- package/demo/index.html +0 -13
- package/demo/package-lock.json +0 -3495
- package/demo/package.json +0 -32
- package/demo/public/icon.svg +0 -6
- package/demo/tsconfig.app.json +0 -27
- package/demo/tsconfig.node.json +0 -25
- package/demo/vite.config.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/models/achievement.d.ts +0 -20
- package/dist/models/achievement.d.ts.map +0 -1
- package/dist/models/achievement.js +0 -1
- package/dist/models/activity.d.ts +0 -11
- package/dist/models/activity.d.ts.map +0 -1
- package/dist/models/activity.js +0 -1
- package/dist/models/balance.d.ts +0 -6
- package/dist/models/balance.d.ts.map +0 -1
- package/dist/models/balance.js +0 -1
- package/dist/models/environment.d.ts +0 -8
- package/dist/models/environment.d.ts.map +0 -1
- package/dist/models/environment.js +0 -6
- package/dist/models/token.d.ts +0 -78
- package/dist/models/token.d.ts.map +0 -1
- package/dist/models/token.js +0 -1
- package/dist/models/transactions.d.ts +0 -13
- package/dist/models/transactions.d.ts.map +0 -1
- package/dist/models/transactions.js +0 -11
- package/dist/models/user.d.ts +0 -13
- package/dist/models/user.d.ts.map +0 -1
- package/dist/models/user.js +0 -1
- package/dist/services/api.d.ts +0 -65
- package/dist/services/api.d.ts.map +0 -1
- package/dist/services/api.js +0 -161
- package/dist/services/api.test.d.ts +0 -2
- package/dist/services/api.test.d.ts.map +0 -1
- package/dist/services/api.test.js +0 -68
- package/dist/services/canister.d.ts +0 -72
- package/dist/services/canister.d.ts.map +0 -1
- package/dist/services/canister.js +0 -208
- package/dist/services/connect.d.ts +0 -41
- package/dist/services/connect.d.ts.map +0 -1
- package/dist/services/connect.js +0 -105
- package/dist/services/connected-user.d.ts +0 -73
- package/dist/services/connected-user.d.ts.map +0 -1
- package/dist/services/connected-user.js +0 -97
- package/dist/services/http.d.ts +0 -10
- package/dist/services/http.d.ts.map +0 -1
- package/dist/services/http.js +0 -43
- package/dist/services/http.test.d.ts +0 -2
- package/dist/services/http.test.d.ts.map +0 -1
- package/dist/services/http.test.js +0 -37
- package/dist/services/window.d.ts +0 -12
- package/dist/services/window.d.ts.map +0 -1
- package/dist/services/window.js +0 -21
- package/dist/utils/conver-to-odin-amount.test.d.ts +0 -2
- package/dist/utils/conver-to-odin-amount.test.d.ts.map +0 -1
- package/dist/utils/conver-to-odin-amount.test.js +0 -36
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -134
- package/dist/utils/token-field-validators.test.d.ts +0 -2
- package/dist/utils/token-field-validators.test.d.ts.map +0 -1
- package/dist/utils/token-field-validators.test.js +0 -31
- package/vitest.config.ts +0 -7
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { OdinApiClient } from "./api";
|
|
2
|
-
import { AppInitOptions } from "./connect";
|
|
3
|
-
import { WindowClient } from "./window";
|
|
4
|
-
export interface SellOptions {
|
|
5
|
-
principal: string;
|
|
6
|
-
token: string;
|
|
7
|
-
tokenAmount: bigint;
|
|
8
|
-
}
|
|
9
|
-
export interface BuyOptions {
|
|
10
|
-
principal: string;
|
|
11
|
-
token: string;
|
|
12
|
-
btcAmount: bigint;
|
|
13
|
-
}
|
|
14
|
-
export interface TransferOptions {
|
|
15
|
-
principal: string;
|
|
16
|
-
token: string;
|
|
17
|
-
amount: bigint;
|
|
18
|
-
destination: string;
|
|
19
|
-
}
|
|
20
|
-
export interface AddLiquidityOptions {
|
|
21
|
-
principal: string;
|
|
22
|
-
btcAmount: bigint;
|
|
23
|
-
token: string;
|
|
24
|
-
}
|
|
25
|
-
export interface RemoveLiquidityOptions {
|
|
26
|
-
principal: string;
|
|
27
|
-
lpAmount: bigint;
|
|
28
|
-
token: string;
|
|
29
|
-
}
|
|
30
|
-
export interface SwapOptions {
|
|
31
|
-
principal: string;
|
|
32
|
-
fromToken: string;
|
|
33
|
-
toToken: string;
|
|
34
|
-
fromAmount: bigint;
|
|
35
|
-
}
|
|
36
|
-
export interface IcrcApproveOptions {
|
|
37
|
-
principal: string;
|
|
38
|
-
token: string;
|
|
39
|
-
spender: string;
|
|
40
|
-
amount: bigint;
|
|
41
|
-
}
|
|
42
|
-
export interface CreateTokenParams {
|
|
43
|
-
principal: string;
|
|
44
|
-
name: string;
|
|
45
|
-
ticker: string;
|
|
46
|
-
image: File;
|
|
47
|
-
description?: string;
|
|
48
|
-
website?: string;
|
|
49
|
-
twitter?: string;
|
|
50
|
-
telegram?: string;
|
|
51
|
-
buy?: bigint;
|
|
52
|
-
discount?: string;
|
|
53
|
-
}
|
|
54
|
-
export declare class OdinCanisterClient {
|
|
55
|
-
private _window;
|
|
56
|
-
private _appInfo;
|
|
57
|
-
private _api;
|
|
58
|
-
origin: string;
|
|
59
|
-
constructor(windowClient: WindowClient, apiClient: OdinApiClient, appInfo: AppInitOptions, origin: string);
|
|
60
|
-
get appInfo(): AppInitOptions;
|
|
61
|
-
private createUrl;
|
|
62
|
-
private baseAction;
|
|
63
|
-
sell({ token, tokenAmount, principal }: SellOptions): Promise<boolean>;
|
|
64
|
-
buy({ principal, token, btcAmount }: BuyOptions): Promise<boolean>;
|
|
65
|
-
transfer({ principal, token, amount, destination }: TransferOptions): Promise<boolean>;
|
|
66
|
-
addLiquidity({ principal, btcAmount, token }: AddLiquidityOptions): Promise<boolean>;
|
|
67
|
-
removeLiquidity({ principal, lpAmount, token }: RemoveLiquidityOptions): Promise<boolean>;
|
|
68
|
-
swap({ principal, fromToken: from, toToken: to, fromAmount }: SwapOptions): Promise<boolean>;
|
|
69
|
-
icrcApprove({ principal, token, spender, amount }: IcrcApproveOptions): Promise<boolean>;
|
|
70
|
-
createToken({ image, ...params }: CreateTokenParams): Promise<boolean>;
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=canister.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"canister.d.ts","sourceRoot":"","sources":["../../src/services/canister.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,cAAc,EAAW,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,IAAI,CAAgB;IAC5B,MAAM,EAAE,MAAM,CAAC;gBAGb,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,aAAa,EACxB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,MAAM;IAQhB,IAAI,OAAO,mBAEV;IAED,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,UAAU;IAuDlB,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,WAAW;IAiBnD,GAAG,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,UAAU;IAiB/C,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,eAAe;IAkBnE,YAAY,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,mBAAmB;IAiBjE,eAAe,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,sBAAsB;IAiBtE,IAAI,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,WAAW;IAkBzE,WAAW,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,kBAAkB;IAkB/D,WAAW,CAAC,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,EAAE,iBAAiB;CAyC1D"}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { createTokenValidators } from "../utils";
|
|
2
|
-
export class OdinCanisterClient {
|
|
3
|
-
_window;
|
|
4
|
-
_appInfo;
|
|
5
|
-
_api;
|
|
6
|
-
origin;
|
|
7
|
-
constructor(windowClient, apiClient, appInfo, origin) {
|
|
8
|
-
this._window = windowClient;
|
|
9
|
-
this._api = apiClient;
|
|
10
|
-
this._appInfo = appInfo;
|
|
11
|
-
this.origin = origin;
|
|
12
|
-
}
|
|
13
|
-
get appInfo() {
|
|
14
|
-
return this._appInfo;
|
|
15
|
-
}
|
|
16
|
-
createUrl(path) {
|
|
17
|
-
const url = new URL(`${this.origin}/${path}`);
|
|
18
|
-
if (this._appInfo?.name) {
|
|
19
|
-
url.searchParams.append("app_name", this._appInfo.name);
|
|
20
|
-
}
|
|
21
|
-
url.searchParams.append("referrer", window.location.origin);
|
|
22
|
-
return url;
|
|
23
|
-
}
|
|
24
|
-
baseAction({ params, odinPath, receivedMessageFromOrigin, resolve: resolveMessages, }) {
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
const handleMessage = async (event) => {
|
|
27
|
-
if (event.origin === this.origin &&
|
|
28
|
-
event.data.path === "/" + odinPath) {
|
|
29
|
-
window.removeEventListener("message", handleMessage);
|
|
30
|
-
if (typeof receivedMessageFromOrigin === "function"
|
|
31
|
-
? receivedMessageFromOrigin(event.data.message)
|
|
32
|
-
: receivedMessageFromOrigin === event.data.message) {
|
|
33
|
-
resolve(resolveMessages.success(event.data.message));
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
reject(new Error(resolveMessages.failure));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const url = this.createUrl(odinPath);
|
|
41
|
-
for (const key in params) {
|
|
42
|
-
// exclude undefined params
|
|
43
|
-
if (params[key]) {
|
|
44
|
-
url.searchParams.append(key, params[key]);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const opened = this._window.open(url);
|
|
48
|
-
if (!opened || opened.closed || typeof opened.closed === "undefined") {
|
|
49
|
-
reject(new Error(resolveMessages.didnotopen ??
|
|
50
|
-
`Failed to open ${odinPath} window, please always allow popups and try again`));
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
window.addEventListener("message", handleMessage);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
sell({ token, tokenAmount, principal }) {
|
|
57
|
-
return this.baseAction({
|
|
58
|
-
params: {
|
|
59
|
-
principal,
|
|
60
|
-
token,
|
|
61
|
-
amount: tokenAmount.toString(),
|
|
62
|
-
},
|
|
63
|
-
odinPath: "authorize/sell",
|
|
64
|
-
receivedMessageFromOrigin: "sold",
|
|
65
|
-
resolve: {
|
|
66
|
-
success: () => true,
|
|
67
|
-
failure: "Sell failed or was cancelled",
|
|
68
|
-
close: "User closed the window",
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
buy({ principal, token, btcAmount }) {
|
|
73
|
-
return this.baseAction({
|
|
74
|
-
params: {
|
|
75
|
-
principal,
|
|
76
|
-
token,
|
|
77
|
-
amount: btcAmount.toString(),
|
|
78
|
-
},
|
|
79
|
-
odinPath: "authorize/buy",
|
|
80
|
-
receivedMessageFromOrigin: "purchased",
|
|
81
|
-
resolve: {
|
|
82
|
-
success: () => true,
|
|
83
|
-
failure: "Purchase failed or was cancelled",
|
|
84
|
-
close: "User closed the window",
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
transfer({ principal, token, amount, destination }) {
|
|
89
|
-
return this.baseAction({
|
|
90
|
-
params: {
|
|
91
|
-
principal,
|
|
92
|
-
token,
|
|
93
|
-
amount: amount.toString(),
|
|
94
|
-
destination,
|
|
95
|
-
},
|
|
96
|
-
odinPath: "authorize/transfer",
|
|
97
|
-
receivedMessageFromOrigin: "transferred",
|
|
98
|
-
resolve: {
|
|
99
|
-
success: () => true,
|
|
100
|
-
failure: "Transfer failed or was cancelled",
|
|
101
|
-
close: "User closed the window",
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
addLiquidity({ principal, btcAmount, token }) {
|
|
106
|
-
return this.baseAction({
|
|
107
|
-
params: {
|
|
108
|
-
principal,
|
|
109
|
-
amount: btcAmount.toString(),
|
|
110
|
-
token,
|
|
111
|
-
},
|
|
112
|
-
odinPath: "authorize/add_liquidity",
|
|
113
|
-
receivedMessageFromOrigin: "addedLiquidity",
|
|
114
|
-
resolve: {
|
|
115
|
-
success: () => true,
|
|
116
|
-
failure: "Add liquidity failed or was cancelled",
|
|
117
|
-
close: "User closed the window",
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
removeLiquidity({ principal, lpAmount, token }) {
|
|
122
|
-
return this.baseAction({
|
|
123
|
-
params: {
|
|
124
|
-
principal,
|
|
125
|
-
amount: lpAmount.toString(),
|
|
126
|
-
token,
|
|
127
|
-
},
|
|
128
|
-
odinPath: "authorize/remove_liquidity",
|
|
129
|
-
receivedMessageFromOrigin: "removedLiquidity",
|
|
130
|
-
resolve: {
|
|
131
|
-
success: () => true,
|
|
132
|
-
failure: "Remove liquidity failed or was cancelled",
|
|
133
|
-
close: "User closed the window",
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
swap({ principal, fromToken: from, toToken: to, fromAmount }) {
|
|
138
|
-
return this.baseAction({
|
|
139
|
-
params: {
|
|
140
|
-
principal,
|
|
141
|
-
from,
|
|
142
|
-
to,
|
|
143
|
-
amount: fromAmount.toString(),
|
|
144
|
-
},
|
|
145
|
-
odinPath: "authorize/swap",
|
|
146
|
-
receivedMessageFromOrigin: "swapped",
|
|
147
|
-
resolve: {
|
|
148
|
-
success: () => true,
|
|
149
|
-
failure: "Swap failed or was cancelled",
|
|
150
|
-
close: "User closed the window",
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
icrcApprove({ principal, token, spender, amount }) {
|
|
155
|
-
return this.baseAction({
|
|
156
|
-
params: {
|
|
157
|
-
principal,
|
|
158
|
-
token,
|
|
159
|
-
spender,
|
|
160
|
-
amount: amount.toString(),
|
|
161
|
-
},
|
|
162
|
-
odinPath: "authorize/icrc_approve",
|
|
163
|
-
receivedMessageFromOrigin: "approved",
|
|
164
|
-
resolve: {
|
|
165
|
-
success: () => true,
|
|
166
|
-
failure: "ICRC approve failed or was cancelled",
|
|
167
|
-
close: "User closed the window",
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
async createToken({ image, ...params }) {
|
|
172
|
-
// check if token field param validators exist and run them
|
|
173
|
-
for (const key in createTokenValidators) {
|
|
174
|
-
if (key in params) {
|
|
175
|
-
const field = key;
|
|
176
|
-
const errors = createTokenValidators[field]?.(params[key] || null);
|
|
177
|
-
if (errors) {
|
|
178
|
-
throw new Error(errors);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
// additional validations for discount code
|
|
183
|
-
if (params.discount) {
|
|
184
|
-
if (!/^[A-Za-z0-9]{10}$/.test(params.discount)) {
|
|
185
|
-
throw new Error("Discount code must be alphanumeric and exactly 10 characters long.");
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
const imageUrl = await this._api.uploadImage(image);
|
|
189
|
-
const result = await this.baseAction({
|
|
190
|
-
params: {
|
|
191
|
-
...params,
|
|
192
|
-
image: imageUrl,
|
|
193
|
-
buy: params.buy?.toString(),
|
|
194
|
-
},
|
|
195
|
-
odinPath: "authorize/create_token",
|
|
196
|
-
receivedMessageFromOrigin: "tokenCreated",
|
|
197
|
-
resolve: {
|
|
198
|
-
success: () => true,
|
|
199
|
-
failure: "Token creation failed or was cancelled",
|
|
200
|
-
close: "User closed the window",
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
if (!result) {
|
|
204
|
-
throw new Error("Token creation failed. Please try again.");
|
|
205
|
-
}
|
|
206
|
-
return true;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { OdinApiClient } from "./api";
|
|
2
|
-
import { ConnectedUser } from "./connected-user";
|
|
3
|
-
import { Environment } from "../models/environment";
|
|
4
|
-
import { WindowClientSettings } from "./window";
|
|
5
|
-
import { OdinCanisterClient } from "./canister";
|
|
6
|
-
export interface AppInitOptions {
|
|
7
|
-
name: string;
|
|
8
|
-
icon?: string;
|
|
9
|
-
env?: Environment;
|
|
10
|
-
}
|
|
11
|
-
interface BaseConnectOptions {
|
|
12
|
-
open?: WindowClientSettings;
|
|
13
|
-
requires_api?: boolean;
|
|
14
|
-
}
|
|
15
|
-
interface ConnectOptionsWithDelegation extends BaseConnectOptions {
|
|
16
|
-
requires_delegation: true;
|
|
17
|
-
targets: string[];
|
|
18
|
-
}
|
|
19
|
-
interface ConnectOptionsWithoutDelegation extends BaseConnectOptions {
|
|
20
|
-
requires_delegation?: false;
|
|
21
|
-
targets?: never;
|
|
22
|
-
session_key?: never;
|
|
23
|
-
}
|
|
24
|
-
type ConnectOptions = ConnectOptionsWithDelegation | ConnectOptionsWithoutDelegation;
|
|
25
|
-
export declare class Connect {
|
|
26
|
-
private _appInfo;
|
|
27
|
-
private _api;
|
|
28
|
-
private _window;
|
|
29
|
-
private _odin;
|
|
30
|
-
constructor(appInfo?: Partial<AppInitOptions>);
|
|
31
|
-
private createUrl;
|
|
32
|
-
get origin(): string;
|
|
33
|
-
get appInfo(): AppInitOptions | null;
|
|
34
|
-
connect({ open, requires_api, requires_delegation, targets, }?: ConnectOptions | undefined): Promise<ConnectedUser>;
|
|
35
|
-
get api(): OdinApiClient;
|
|
36
|
-
get odin(): OdinCanisterClient;
|
|
37
|
-
get currentEnv(): "prod" | "dev" | "local" | "_preview";
|
|
38
|
-
hello(): void;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
41
|
-
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/services/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoB,MAAM,OAAO,CAAC;AAOxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAW,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAgB,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,WAAW,CAAC;CACnB;AACD,UAAU,kBAAkB;IAE1B,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAE5B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,UAAU,4BAA6B,SAAQ,kBAAkB;IAE/D,mBAAmB,EAAE,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,UAAU,+BAAgC,SAAQ,kBAAkB;IAClE,mBAAmB,CAAC,EAAE,KAAK,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB;AAED,KAAK,cAAc,GACf,4BAA4B,GAC5B,+BAA+B,CAAC;AAWpC,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,KAAK,CAAqB;gBAEtB,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAkB7C,OAAO,CAAC,SAAS;IASjB,IAAI,MAAM,WAET;IAED,IAAI,OAAO,0BAEV;IAED,OAAO,CACL,EACE,IAAI,EACJ,YAAY,EACZ,mBAAmB,EACnB,OAAO,GACR,GAAE,cAAc,GAAG,SAGnB,GACA,OAAO,CAAC,aAAa,CAAC;IA2EzB,IAAI,GAAG,kBAEN;IAED,IAAI,IAAI,uBAEP;IAED,IAAI,UAAU,0CAEb;IAED,KAAK;CAGN"}
|
package/dist/services/connect.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { OdinApiClient } from "./api";
|
|
2
|
-
import { DelegationChain, DelegationIdentity, Ed25519KeyIdentity, } from "@dfinity/identity";
|
|
3
|
-
import { ConnectedUser } from "./connected-user";
|
|
4
|
-
import { ORIGINS } from "../models/environment";
|
|
5
|
-
import { WindowClient } from "./window";
|
|
6
|
-
import { OdinCanisterClient } from "./canister";
|
|
7
|
-
export class Connect {
|
|
8
|
-
_appInfo = null;
|
|
9
|
-
_api;
|
|
10
|
-
_window;
|
|
11
|
-
_odin;
|
|
12
|
-
constructor(appInfo) {
|
|
13
|
-
this._appInfo = {
|
|
14
|
-
env: "prod",
|
|
15
|
-
name: "app_name",
|
|
16
|
-
...appInfo,
|
|
17
|
-
};
|
|
18
|
-
this._api = new OdinApiClient(this._appInfo.env === "prod" ? "prod" : "dev");
|
|
19
|
-
this._window = new WindowClient();
|
|
20
|
-
this._odin = new OdinCanisterClient(this._window, this._api, this._appInfo, ORIGINS[this._appInfo.env || "prod"]);
|
|
21
|
-
}
|
|
22
|
-
createUrl(path) {
|
|
23
|
-
const url = new URL(`${this.origin}/${path}`);
|
|
24
|
-
if (this._appInfo?.name) {
|
|
25
|
-
url.searchParams.append("app_name", this._appInfo.name);
|
|
26
|
-
}
|
|
27
|
-
url.searchParams.append("referrer", window.location.origin);
|
|
28
|
-
return url;
|
|
29
|
-
}
|
|
30
|
-
get origin() {
|
|
31
|
-
return ORIGINS[this._appInfo?.env || "prod"];
|
|
32
|
-
}
|
|
33
|
-
get appInfo() {
|
|
34
|
-
return this._appInfo;
|
|
35
|
-
}
|
|
36
|
-
connect({ open, requires_api, requires_delegation, targets, } = {
|
|
37
|
-
requires_delegation: false,
|
|
38
|
-
requires_api: false,
|
|
39
|
-
}) {
|
|
40
|
-
return new Promise((resolve, reject) => {
|
|
41
|
-
if (open) {
|
|
42
|
-
this._window.settings = open;
|
|
43
|
-
}
|
|
44
|
-
const sessionKey = Ed25519KeyIdentity.generate();
|
|
45
|
-
const handleMessage = async (event) => {
|
|
46
|
-
if (event.origin === this.origin &&
|
|
47
|
-
event.data.path === "/authorize/connect") {
|
|
48
|
-
window.removeEventListener("message", handleMessage);
|
|
49
|
-
if (event.data.message != "rejected") {
|
|
50
|
-
let connectedUser;
|
|
51
|
-
// the user accepted the connection
|
|
52
|
-
try {
|
|
53
|
-
const eventData = event.data.message;
|
|
54
|
-
const { principal, jwt: jwtToken, delegationChain } = eventData;
|
|
55
|
-
if (requires_api) {
|
|
56
|
-
// issue a api key
|
|
57
|
-
// only using JWT for now, it will change in the real implementation
|
|
58
|
-
this._api.apiKey = jwtToken;
|
|
59
|
-
}
|
|
60
|
-
if (requires_delegation) {
|
|
61
|
-
if (!delegationChain) {
|
|
62
|
-
throw new Error("Delegation chain is missing");
|
|
63
|
-
}
|
|
64
|
-
const identity = DelegationIdentity.fromDelegation(sessionKey, DelegationChain.fromJSON(delegationChain));
|
|
65
|
-
connectedUser = new ConnectedUser(principal, identity, this.api, this._odin);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
connectedUser = new ConnectedUser(principal, null, this.api, this._odin);
|
|
69
|
-
}
|
|
70
|
-
resolve(connectedUser);
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
reject(new Error("Failed to fetch user data"));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
reject(new Error("User rejected the connection"));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const url = this.createUrl("authorize/connect");
|
|
82
|
-
url.searchParams.append("requires_api", requires_api ? "1" : "0");
|
|
83
|
-
if (requires_delegation) {
|
|
84
|
-
url.searchParams.append("requires_delegation", "1");
|
|
85
|
-
const sessionString = btoa(JSON.stringify(sessionKey.toJSON()));
|
|
86
|
-
url.searchParams.append("session_key", sessionString);
|
|
87
|
-
url.searchParams.append("targets", targets?.join(",") || "");
|
|
88
|
-
}
|
|
89
|
-
this._window.open(url);
|
|
90
|
-
window.addEventListener("message", handleMessage);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
get api() {
|
|
94
|
-
return this._api;
|
|
95
|
-
}
|
|
96
|
-
get odin() {
|
|
97
|
-
return this._odin;
|
|
98
|
-
}
|
|
99
|
-
get currentEnv() {
|
|
100
|
-
return this._appInfo?.env || "prod";
|
|
101
|
-
}
|
|
102
|
-
hello() {
|
|
103
|
-
console.log("Hello from Odin Connect!");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { DelegationIdentity } from "@dfinity/identity";
|
|
2
|
-
import { OdinApiClient } from "./api";
|
|
3
|
-
import { AddLiquidityOptions, BuyOptions, CreateTokenParams, IcrcApproveOptions, OdinCanisterClient, RemoveLiquidityOptions, SellOptions, SwapOptions, TransferOptions } from "./canister";
|
|
4
|
-
export declare class ConnectedUser {
|
|
5
|
-
private _identity;
|
|
6
|
-
private _api;
|
|
7
|
-
private _principal;
|
|
8
|
-
private _odin;
|
|
9
|
-
constructor(principal: string, identity: DelegationIdentity | null, api: OdinApiClient, odin: OdinCanisterClient);
|
|
10
|
-
get principal(): string;
|
|
11
|
-
set principal(principal: string);
|
|
12
|
-
getIdentity(): DelegationIdentity | null;
|
|
13
|
-
getUser(): Promise<import("..").OdinUser>;
|
|
14
|
-
getBalances(pagination: {
|
|
15
|
-
page: number;
|
|
16
|
-
limit: number;
|
|
17
|
-
}): Promise<readonly import("..").OdinBalance[]>;
|
|
18
|
-
getTokens(pagination: {
|
|
19
|
-
page: number;
|
|
20
|
-
limit: number;
|
|
21
|
-
}): Promise<{
|
|
22
|
-
data: {
|
|
23
|
-
balance: bigint;
|
|
24
|
-
token: import("..").OdinToken;
|
|
25
|
-
unrealized_pnl?: number;
|
|
26
|
-
unrealized_pnl_percent?: number;
|
|
27
|
-
}[];
|
|
28
|
-
count: number;
|
|
29
|
-
page: number;
|
|
30
|
-
limit: number;
|
|
31
|
-
}>;
|
|
32
|
-
getCreatedTokens(pagination: {
|
|
33
|
-
page: number;
|
|
34
|
-
limit: number;
|
|
35
|
-
}): Promise<import("./api").PaginatedResponse<import("..").OdinToken>>;
|
|
36
|
-
getActivity(pagination: {
|
|
37
|
-
page: number;
|
|
38
|
-
limit: number;
|
|
39
|
-
}): Promise<import("./api").PaginatedResponse<import("..").OdinActivity>>;
|
|
40
|
-
getLiquidity(pagination: {
|
|
41
|
-
page: number;
|
|
42
|
-
limit: number;
|
|
43
|
-
}): Promise<{
|
|
44
|
-
data: {
|
|
45
|
-
balance: bigint;
|
|
46
|
-
token: import("..").OdinToken;
|
|
47
|
-
}[];
|
|
48
|
-
count: number;
|
|
49
|
-
page: number;
|
|
50
|
-
limit: number;
|
|
51
|
-
}>;
|
|
52
|
-
getAchievements(pagination: {
|
|
53
|
-
page: number;
|
|
54
|
-
limit: number;
|
|
55
|
-
}): Promise<readonly import("..").OdinAchievementCategory[]>;
|
|
56
|
-
getTransactions(pagination: {
|
|
57
|
-
page: number;
|
|
58
|
-
limit: number;
|
|
59
|
-
}): Promise<import("./api").PaginatedResponse<import("..").OdinTransaction>>;
|
|
60
|
-
getStats(): Promise<{
|
|
61
|
-
followers: number;
|
|
62
|
-
following: number;
|
|
63
|
-
}>;
|
|
64
|
-
sell(params: Omit<SellOptions, "principal">): Promise<boolean>;
|
|
65
|
-
buy(params: Omit<BuyOptions, "principal">): Promise<boolean>;
|
|
66
|
-
addLiquidity(params: Omit<AddLiquidityOptions, "principal">): Promise<boolean>;
|
|
67
|
-
removeLiquidity(params: Omit<RemoveLiquidityOptions, "principal">): Promise<boolean>;
|
|
68
|
-
transfer(params: Omit<TransferOptions, "principal">): Promise<boolean>;
|
|
69
|
-
createToken(params: Omit<CreateTokenParams, "principal">): Promise<boolean>;
|
|
70
|
-
icrcApprove(params: Omit<IcrcApproveOptions, "principal">): Promise<boolean>;
|
|
71
|
-
swap(params: Omit<SwapOptions, "principal">): Promise<boolean>;
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=connected-user.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connected-user.d.ts","sourceRoot":"","sources":["../../src/services/connected-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,qBAAa,aAAa;IACxB,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,KAAK,CAAqB;gBAGhC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,kBAAkB,GAAG,IAAI,EACnC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,kBAAkB;IAQ1B,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,EAE9B;IAED,WAAW,IAAI,kBAAkB,GAAG,IAAI;IAIxC,OAAO;IAIP,WAAW,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAIvD,SAAS,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;IAIrD,gBAAgB,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAI5D,WAAW,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAIvD,YAAY,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;;;;;;;;;IAIxD,eAAe,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAI3D,eAAe,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAI3D,QAAQ;;;;IAMR,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;IAO3C,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC;IAOzC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC;IAO3D,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,sBAAsB,EAAE,WAAW,CAAC;IAOjE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC;IAOnD,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC;IAOxD,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC;IAOzD,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC;CAM5C"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
export class ConnectedUser {
|
|
2
|
-
_identity;
|
|
3
|
-
_api;
|
|
4
|
-
_principal;
|
|
5
|
-
_odin;
|
|
6
|
-
constructor(principal, identity, api, odin) {
|
|
7
|
-
this._principal = principal;
|
|
8
|
-
this._identity = identity;
|
|
9
|
-
this._api = api;
|
|
10
|
-
this._odin = odin;
|
|
11
|
-
}
|
|
12
|
-
get principal() {
|
|
13
|
-
return this._principal;
|
|
14
|
-
}
|
|
15
|
-
set principal(principal) {
|
|
16
|
-
this._principal = principal;
|
|
17
|
-
}
|
|
18
|
-
getIdentity() {
|
|
19
|
-
return this._identity;
|
|
20
|
-
}
|
|
21
|
-
getUser() {
|
|
22
|
-
return this._api.getUser(this.principal);
|
|
23
|
-
}
|
|
24
|
-
getBalances(pagination) {
|
|
25
|
-
return this._api.getBalances(this.principal, pagination);
|
|
26
|
-
}
|
|
27
|
-
getTokens(pagination) {
|
|
28
|
-
return this._api.getUserTokens(this.principal, pagination);
|
|
29
|
-
}
|
|
30
|
-
getCreatedTokens(pagination) {
|
|
31
|
-
return this._api.getUserCreatedTokens(this.principal, pagination);
|
|
32
|
-
}
|
|
33
|
-
getActivity(pagination) {
|
|
34
|
-
return this._api.getUserActivity(this.principal, pagination);
|
|
35
|
-
}
|
|
36
|
-
getLiquidity(pagination) {
|
|
37
|
-
return this._api.getUserLiquidity(this.principal, pagination);
|
|
38
|
-
}
|
|
39
|
-
getAchievements(pagination) {
|
|
40
|
-
return this._api.getUserAchievements(this.principal, pagination);
|
|
41
|
-
}
|
|
42
|
-
getTransactions(pagination) {
|
|
43
|
-
return this._api.getUserTransactions(this.principal, pagination);
|
|
44
|
-
}
|
|
45
|
-
getStats() {
|
|
46
|
-
return this._api.getUserStats(this.principal);
|
|
47
|
-
}
|
|
48
|
-
/// others
|
|
49
|
-
sell(params) {
|
|
50
|
-
return this._odin.sell({
|
|
51
|
-
...params,
|
|
52
|
-
principal: this.principal,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
buy(params) {
|
|
56
|
-
return this._odin.buy({
|
|
57
|
-
...params,
|
|
58
|
-
principal: this.principal,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
addLiquidity(params) {
|
|
62
|
-
return this._odin.addLiquidity({
|
|
63
|
-
...params,
|
|
64
|
-
principal: this.principal,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
removeLiquidity(params) {
|
|
68
|
-
return this._odin.removeLiquidity({
|
|
69
|
-
...params,
|
|
70
|
-
principal: this.principal,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
transfer(params) {
|
|
74
|
-
return this._odin.transfer({
|
|
75
|
-
...params,
|
|
76
|
-
principal: this.principal,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
createToken(params) {
|
|
80
|
-
return this._odin.createToken({
|
|
81
|
-
...params,
|
|
82
|
-
principal: this.principal,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
icrcApprove(params) {
|
|
86
|
-
return this._odin.icrcApprove({
|
|
87
|
-
...params,
|
|
88
|
-
principal: this.principal,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
swap(params) {
|
|
92
|
-
return this._odin.swap({
|
|
93
|
-
...params,
|
|
94
|
-
principal: this.principal,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
package/dist/services/http.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from "axios";
|
|
2
|
-
export declare const bigIntTransformer: (data: string) => any;
|
|
3
|
-
export declare class HttpClient {
|
|
4
|
-
get<ResponseType>(url: string, options?: AxiosRequestConfig): Promise<ResponseType>;
|
|
5
|
-
fetch<ResponseType>(url: string, options?: AxiosRequestConfig): Promise<ResponseType>;
|
|
6
|
-
post<ResponseType, DataType = string>(url: string, data?: DataType, options?: AxiosRequestConfig): Promise<ResponseType>;
|
|
7
|
-
put<DataType, ResponseType>(url: string, data?: DataType, options?: AxiosRequestConfig): Promise<ResponseType>;
|
|
8
|
-
delete<ResponseType>(url: string, options?: AxiosRequestConfig): Promise<ResponseType>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=http.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/services/http.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,kBAAkB,EAA4B,MAAM,OAAO,CAAC;AAG5E,eAAO,MAAM,iBAAiB,GACzB,MAAK,MAAM,QAOX,CAAA;AACL,qBAAa,UAAU;IAEf,GAAG,CAAC,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB;IAI3D,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB;IAW7D,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,MAAM,EACxC,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,QAAQ,EACf,OAAO,CAAC,EAAE,kBAAkB;IASxB,GAAG,CAAC,QAAQ,EAAE,YAAY,EAC9B,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,QAAQ,EACf,OAAO,CAAC,EAAE,kBAAkB;IASxB,MAAM,CAAC,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB;CAGrE"}
|
package/dist/services/http.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import JSONBigInt from "@apimatic/json-bigint";
|
|
3
|
-
export const bigIntTransformer = (data) => {
|
|
4
|
-
try {
|
|
5
|
-
return JSONBigInt.parse(data);
|
|
6
|
-
}
|
|
7
|
-
catch (e) {
|
|
8
|
-
console.error("Error parsing response:", e);
|
|
9
|
-
return data;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
export class HttpClient {
|
|
13
|
-
async get(url, options) {
|
|
14
|
-
return this.fetch(url, { method: "GET", ...options });
|
|
15
|
-
}
|
|
16
|
-
async fetch(url, options) {
|
|
17
|
-
// for any custom headers or other axios options in the future
|
|
18
|
-
// should we add Auth bearer token here if available?
|
|
19
|
-
const overrides = {
|
|
20
|
-
transformResponse: [bigIntTransformer],
|
|
21
|
-
...options,
|
|
22
|
-
};
|
|
23
|
-
const response = await axios(url, overrides);
|
|
24
|
-
return response.data;
|
|
25
|
-
}
|
|
26
|
-
async post(url, data, options) {
|
|
27
|
-
return this.fetch(url, {
|
|
28
|
-
method: "POST",
|
|
29
|
-
data,
|
|
30
|
-
...options,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
async put(url, data, options) {
|
|
34
|
-
return this.fetch(url, {
|
|
35
|
-
method: "PUT",
|
|
36
|
-
data,
|
|
37
|
-
...options,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
async delete(url, options) {
|
|
41
|
-
return this.fetch(url, { method: "DELETE", ...options });
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.test.d.ts","sourceRoot":"","sources":["../../src/services/http.test.ts"],"names":[],"mappings":""}
|