@nightlylabs/dex-sdk 0.0.70 → 0.0.71
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.cjs +42 -19
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +47 -23
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1093,7 +1093,7 @@ var Client = class _Client {
|
|
|
1093
1093
|
this._ws?.send(JSON.stringify(message));
|
|
1094
1094
|
});
|
|
1095
1095
|
}
|
|
1096
|
-
static async create(connection, apiKey, url = "
|
|
1096
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1097
1097
|
return _Client.init(connection, apiKey, url, enableWs);
|
|
1098
1098
|
}
|
|
1099
1099
|
async setApiKey(apiKey) {
|
|
@@ -1114,16 +1114,25 @@ var Client = class _Client {
|
|
|
1114
1114
|
// needs to be signed by user and sent to blockchain
|
|
1115
1115
|
async createUser(params) {
|
|
1116
1116
|
const apiKey = generateApiKey();
|
|
1117
|
-
const payload = (0,
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1117
|
+
const payload = await (0, import_ts_sdk2.generateTransactionPayload)({
|
|
1118
|
+
aptosConfig: this._aptos.config,
|
|
1119
|
+
abi: parseEntryFunctionAbi({
|
|
1120
|
+
moduleAbi: createUser_default,
|
|
1121
|
+
functionName: createUser_default.name,
|
|
1122
|
+
moduleAddress: createUser_default.address,
|
|
1123
|
+
moduleName: createUser_default.name
|
|
1124
|
+
}),
|
|
1125
|
+
function: `${createUser_default.address}::${createUser_default.name}::create_user`,
|
|
1126
|
+
typeArguments: [],
|
|
1127
|
+
functionArguments: [params.name, params.referralId]
|
|
1126
1128
|
});
|
|
1129
|
+
const tx = new import_ts_sdk2.SimpleTransaction(
|
|
1130
|
+
await (0, import_ts_sdk2.generateRawTransaction)({
|
|
1131
|
+
sender: params.sender,
|
|
1132
|
+
aptosConfig: this._aptos.config,
|
|
1133
|
+
payload
|
|
1134
|
+
})
|
|
1135
|
+
);
|
|
1127
1136
|
const signature = this._aptos.sign({
|
|
1128
1137
|
signer: apiKey,
|
|
1129
1138
|
transaction: tx
|
|
@@ -1212,10 +1221,17 @@ var Client = class _Client {
|
|
|
1212
1221
|
}
|
|
1213
1222
|
// needs to be signed by user and sent to blockchain
|
|
1214
1223
|
async addApiKey(params) {
|
|
1215
|
-
return (0,
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1224
|
+
return await (0, import_ts_sdk2.generateTransactionPayload)({
|
|
1225
|
+
aptosConfig: this._aptos.config,
|
|
1226
|
+
abi: parseEntryFunctionAbi({
|
|
1227
|
+
moduleAbi: addApiKey_default,
|
|
1228
|
+
functionName: addApiKey_default.name,
|
|
1229
|
+
moduleAddress: addApiKey_default.address,
|
|
1230
|
+
moduleName: addApiKey_default.name
|
|
1231
|
+
}),
|
|
1232
|
+
function: `${addApiKey_default.address}::${addApiKey_default.name}::add_api_key`,
|
|
1233
|
+
typeArguments: [],
|
|
1234
|
+
functionArguments: [params.userId, params.expiration]
|
|
1219
1235
|
});
|
|
1220
1236
|
}
|
|
1221
1237
|
async removeApiKey(params) {
|
|
@@ -1489,10 +1505,17 @@ var Client = class _Client {
|
|
|
1489
1505
|
return await this.submitSponsoredTransaction(tx, signature);
|
|
1490
1506
|
}
|
|
1491
1507
|
async depositTokenPayload(params) {
|
|
1492
|
-
return (0,
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1508
|
+
return await (0, import_ts_sdk2.generateTransactionPayload)({
|
|
1509
|
+
aptosConfig: this._aptos.config,
|
|
1510
|
+
abi: parseEntryFunctionAbi({
|
|
1511
|
+
moduleAbi: depositToken_default,
|
|
1512
|
+
functionName: depositToken_default.name,
|
|
1513
|
+
moduleAddress: depositToken_default.address,
|
|
1514
|
+
moduleName: depositToken_default.name
|
|
1515
|
+
}),
|
|
1516
|
+
function: `${depositToken_default.address}::${depositToken_default.name}::deposit_token`,
|
|
1517
|
+
typeArguments: [],
|
|
1518
|
+
functionArguments: [params.userId, params.amount, params.tokenAddress]
|
|
1496
1519
|
});
|
|
1497
1520
|
}
|
|
1498
1521
|
async depositToVault(params) {
|
|
@@ -1961,7 +1984,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1961
1984
|
constructor(connection, url, ws, apiKey) {
|
|
1962
1985
|
super(connection, url, ws, apiKey);
|
|
1963
1986
|
}
|
|
1964
|
-
static async create(connection, apiKey, url = "
|
|
1987
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1965
1988
|
let ws = void 0;
|
|
1966
1989
|
if (enableWs) {
|
|
1967
1990
|
ws = await client_default.initWebSocket(url);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _aptos_labs_ts_sdk from '@aptos-labs/ts-sdk';
|
|
2
|
-
import { Account, Aptos,
|
|
2
|
+
import { Account, Aptos, SimpleTransaction, AccountAuthenticator, MoveModule, EntryFunctionABI } from '@aptos-labs/ts-sdk';
|
|
3
3
|
import * as _thalalabs_surf_build_types_core from '@thalalabs/surf/build/types/core';
|
|
4
4
|
import * as _thalalabs_surf from '@thalalabs/surf';
|
|
5
5
|
import WebSocket from 'isomorphic-ws';
|
|
@@ -880,7 +880,7 @@ declare class Client {
|
|
|
880
880
|
getApiKeySequenceNumber(): Promise<bigint | null>;
|
|
881
881
|
fetchApiKeySequenceNumber(): Promise<number>;
|
|
882
882
|
createUser(params: CreateUserParams): Promise<{
|
|
883
|
-
tx:
|
|
883
|
+
tx: SimpleTransaction;
|
|
884
884
|
signature: AccountAuthenticator;
|
|
885
885
|
apiKey: _aptos_labs_ts_sdk.Ed25519Account;
|
|
886
886
|
}>;
|
|
@@ -892,7 +892,7 @@ declare class Client {
|
|
|
892
892
|
unsubscribeUserUpdates(userId: string): Promise<void>;
|
|
893
893
|
subscribePerpMarketUpdates(market: string, callback: (data: WsPerpMarketUpdates) => void): Promise<() => Promise<void>>;
|
|
894
894
|
unsubscribePerpMarketUpdates(market: string): Promise<void>;
|
|
895
|
-
addApiKey(params: AddApiKeyParams): Promise<
|
|
895
|
+
addApiKey(params: AddApiKeyParams): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
|
|
896
896
|
removeApiKey(params: RemoveApiKeyParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
897
897
|
setAliasName(params: SetAliasNameParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
898
898
|
placePerpLimitOrder(params: PlacePerpLimitOrderParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
@@ -901,7 +901,7 @@ declare class Client {
|
|
|
901
901
|
cancelPerpOrders(params: CancelPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
902
902
|
cancelAllPerpOrders(params: CancelAllPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
903
903
|
setAutolend(params: SetAutolendParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
904
|
-
depositTokenPayload(params: DepositTokenParams): Promise<
|
|
904
|
+
depositTokenPayload(params: DepositTokenParams): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
|
|
905
905
|
depositToVault(params: DepositToVaultParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
906
906
|
withdrawFromVault(params: WithdrawFromVaultParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
907
907
|
redeemToken(params: RedeemTokenParams): Promise<SubmitSponsoredTransactionResponse>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _aptos_labs_ts_sdk from '@aptos-labs/ts-sdk';
|
|
2
|
-
import { Account, Aptos,
|
|
2
|
+
import { Account, Aptos, SimpleTransaction, AccountAuthenticator, MoveModule, EntryFunctionABI } from '@aptos-labs/ts-sdk';
|
|
3
3
|
import * as _thalalabs_surf_build_types_core from '@thalalabs/surf/build/types/core';
|
|
4
4
|
import * as _thalalabs_surf from '@thalalabs/surf';
|
|
5
5
|
import WebSocket from 'isomorphic-ws';
|
|
@@ -880,7 +880,7 @@ declare class Client {
|
|
|
880
880
|
getApiKeySequenceNumber(): Promise<bigint | null>;
|
|
881
881
|
fetchApiKeySequenceNumber(): Promise<number>;
|
|
882
882
|
createUser(params: CreateUserParams): Promise<{
|
|
883
|
-
tx:
|
|
883
|
+
tx: SimpleTransaction;
|
|
884
884
|
signature: AccountAuthenticator;
|
|
885
885
|
apiKey: _aptos_labs_ts_sdk.Ed25519Account;
|
|
886
886
|
}>;
|
|
@@ -892,7 +892,7 @@ declare class Client {
|
|
|
892
892
|
unsubscribeUserUpdates(userId: string): Promise<void>;
|
|
893
893
|
subscribePerpMarketUpdates(market: string, callback: (data: WsPerpMarketUpdates) => void): Promise<() => Promise<void>>;
|
|
894
894
|
unsubscribePerpMarketUpdates(market: string): Promise<void>;
|
|
895
|
-
addApiKey(params: AddApiKeyParams): Promise<
|
|
895
|
+
addApiKey(params: AddApiKeyParams): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
|
|
896
896
|
removeApiKey(params: RemoveApiKeyParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
897
897
|
setAliasName(params: SetAliasNameParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
898
898
|
placePerpLimitOrder(params: PlacePerpLimitOrderParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
@@ -901,7 +901,7 @@ declare class Client {
|
|
|
901
901
|
cancelPerpOrders(params: CancelPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
902
902
|
cancelAllPerpOrders(params: CancelAllPerpOrdersParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
903
903
|
setAutolend(params: SetAutolendParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
904
|
-
depositTokenPayload(params: DepositTokenParams): Promise<
|
|
904
|
+
depositTokenPayload(params: DepositTokenParams): Promise<_aptos_labs_ts_sdk.TransactionPayloadEntryFunction>;
|
|
905
905
|
depositToVault(params: DepositToVaultParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
906
906
|
withdrawFromVault(params: WithdrawFromVaultParams): Promise<SubmitSponsoredTransactionResponse>;
|
|
907
907
|
redeemToken(params: RedeemTokenParams): Promise<SubmitSponsoredTransactionResponse>;
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
AccountAddress,
|
|
4
4
|
ChainId,
|
|
5
5
|
findFirstNonSignerArg,
|
|
6
|
+
generateRawTransaction,
|
|
6
7
|
generateTransactionPayload,
|
|
7
8
|
parseTypeTag,
|
|
8
9
|
RawTransaction,
|
|
9
10
|
SimpleTransaction
|
|
10
11
|
} from "@aptos-labs/ts-sdk";
|
|
11
|
-
import {
|
|
12
|
+
import { createSurfClient } from "@thalalabs/surf";
|
|
12
13
|
import WebSocket from "isomorphic-ws";
|
|
13
14
|
import { v4 as uuidv4 } from "uuid";
|
|
14
15
|
|
|
@@ -1042,7 +1043,7 @@ var Client = class _Client {
|
|
|
1042
1043
|
this._ws?.send(JSON.stringify(message));
|
|
1043
1044
|
});
|
|
1044
1045
|
}
|
|
1045
|
-
static async create(connection, apiKey, url = "
|
|
1046
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1046
1047
|
return _Client.init(connection, apiKey, url, enableWs);
|
|
1047
1048
|
}
|
|
1048
1049
|
async setApiKey(apiKey) {
|
|
@@ -1063,16 +1064,25 @@ var Client = class _Client {
|
|
|
1063
1064
|
// needs to be signed by user and sent to blockchain
|
|
1064
1065
|
async createUser(params) {
|
|
1065
1066
|
const apiKey = generateApiKey();
|
|
1066
|
-
const payload =
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1067
|
+
const payload = await generateTransactionPayload({
|
|
1068
|
+
aptosConfig: this._aptos.config,
|
|
1069
|
+
abi: parseEntryFunctionAbi({
|
|
1070
|
+
moduleAbi: createUser_default,
|
|
1071
|
+
functionName: createUser_default.name,
|
|
1072
|
+
moduleAddress: createUser_default.address,
|
|
1073
|
+
moduleName: createUser_default.name
|
|
1074
|
+
}),
|
|
1075
|
+
function: `${createUser_default.address}::${createUser_default.name}::create_user`,
|
|
1076
|
+
typeArguments: [],
|
|
1077
|
+
functionArguments: [params.name, params.referralId]
|
|
1075
1078
|
});
|
|
1079
|
+
const tx = new SimpleTransaction(
|
|
1080
|
+
await generateRawTransaction({
|
|
1081
|
+
sender: params.sender,
|
|
1082
|
+
aptosConfig: this._aptos.config,
|
|
1083
|
+
payload
|
|
1084
|
+
})
|
|
1085
|
+
);
|
|
1076
1086
|
const signature = this._aptos.sign({
|
|
1077
1087
|
signer: apiKey,
|
|
1078
1088
|
transaction: tx
|
|
@@ -1161,10 +1171,17 @@ var Client = class _Client {
|
|
|
1161
1171
|
}
|
|
1162
1172
|
// needs to be signed by user and sent to blockchain
|
|
1163
1173
|
async addApiKey(params) {
|
|
1164
|
-
return
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1174
|
+
return await generateTransactionPayload({
|
|
1175
|
+
aptosConfig: this._aptos.config,
|
|
1176
|
+
abi: parseEntryFunctionAbi({
|
|
1177
|
+
moduleAbi: addApiKey_default,
|
|
1178
|
+
functionName: addApiKey_default.name,
|
|
1179
|
+
moduleAddress: addApiKey_default.address,
|
|
1180
|
+
moduleName: addApiKey_default.name
|
|
1181
|
+
}),
|
|
1182
|
+
function: `${addApiKey_default.address}::${addApiKey_default.name}::add_api_key`,
|
|
1183
|
+
typeArguments: [],
|
|
1184
|
+
functionArguments: [params.userId, params.expiration]
|
|
1168
1185
|
});
|
|
1169
1186
|
}
|
|
1170
1187
|
async removeApiKey(params) {
|
|
@@ -1438,10 +1455,17 @@ var Client = class _Client {
|
|
|
1438
1455
|
return await this.submitSponsoredTransaction(tx, signature);
|
|
1439
1456
|
}
|
|
1440
1457
|
async depositTokenPayload(params) {
|
|
1441
|
-
return
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1458
|
+
return await generateTransactionPayload({
|
|
1459
|
+
aptosConfig: this._aptos.config,
|
|
1460
|
+
abi: parseEntryFunctionAbi({
|
|
1461
|
+
moduleAbi: depositToken_default,
|
|
1462
|
+
functionName: depositToken_default.name,
|
|
1463
|
+
moduleAddress: depositToken_default.address,
|
|
1464
|
+
moduleName: depositToken_default.name
|
|
1465
|
+
}),
|
|
1466
|
+
function: `${depositToken_default.address}::${depositToken_default.name}::deposit_token`,
|
|
1467
|
+
typeArguments: [],
|
|
1468
|
+
functionArguments: [params.userId, params.amount, params.tokenAddress]
|
|
1445
1469
|
});
|
|
1446
1470
|
}
|
|
1447
1471
|
async depositToVault(params) {
|
|
@@ -1619,7 +1643,7 @@ function parseEntryFunctionAbi(args) {
|
|
|
1619
1643
|
}
|
|
1620
1644
|
|
|
1621
1645
|
// src/testFaucet.ts
|
|
1622
|
-
import { createEntryPayload
|
|
1646
|
+
import { createEntryPayload } from "@thalalabs/surf";
|
|
1623
1647
|
|
|
1624
1648
|
// generated_types/faucetEntrypoints.ts
|
|
1625
1649
|
var ABI16 = {
|
|
@@ -1910,7 +1934,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1910
1934
|
constructor(connection, url, ws, apiKey) {
|
|
1911
1935
|
super(connection, url, ws, apiKey);
|
|
1912
1936
|
}
|
|
1913
|
-
static async create(connection, apiKey, url = "
|
|
1937
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1914
1938
|
let ws = void 0;
|
|
1915
1939
|
if (enableWs) {
|
|
1916
1940
|
ws = await client_default.initWebSocket(url);
|
|
@@ -1918,7 +1942,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1918
1942
|
return new _TestFaucet(connection, url, ws, apiKey);
|
|
1919
1943
|
}
|
|
1920
1944
|
initFaucetPayload() {
|
|
1921
|
-
return
|
|
1945
|
+
return createEntryPayload(faucetEntrypoints_default, {
|
|
1922
1946
|
function: "initialize_faucet",
|
|
1923
1947
|
functionArguments: [],
|
|
1924
1948
|
typeArguments: []
|
|
@@ -1939,7 +1963,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1939
1963
|
return await this.submitSponsoredTransaction(tx, signature);
|
|
1940
1964
|
}
|
|
1941
1965
|
mintTokenPayload(receiver, token, amount) {
|
|
1942
|
-
return
|
|
1966
|
+
return createEntryPayload(faucetEntrypoints_default, {
|
|
1943
1967
|
function: "mint_test_token",
|
|
1944
1968
|
functionArguments: [receiver, token, amount],
|
|
1945
1969
|
typeArguments: []
|