@nightlylabs/dex-sdk 0.0.70 → 0.0.72
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 +43 -19
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +49 -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,26 @@ 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.MultiAgentTransaction(
|
|
1130
|
+
await (0, import_ts_sdk2.generateRawTransaction)({
|
|
1131
|
+
sender: params.sender,
|
|
1132
|
+
aptosConfig: this._aptos.config,
|
|
1133
|
+
payload
|
|
1134
|
+
}),
|
|
1135
|
+
[apiKey.accountAddress]
|
|
1136
|
+
);
|
|
1127
1137
|
const signature = this._aptos.sign({
|
|
1128
1138
|
signer: apiKey,
|
|
1129
1139
|
transaction: tx
|
|
@@ -1212,10 +1222,17 @@ var Client = class _Client {
|
|
|
1212
1222
|
}
|
|
1213
1223
|
// needs to be signed by user and sent to blockchain
|
|
1214
1224
|
async addApiKey(params) {
|
|
1215
|
-
return (0,
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1225
|
+
return await (0, import_ts_sdk2.generateTransactionPayload)({
|
|
1226
|
+
aptosConfig: this._aptos.config,
|
|
1227
|
+
abi: parseEntryFunctionAbi({
|
|
1228
|
+
moduleAbi: addApiKey_default,
|
|
1229
|
+
functionName: addApiKey_default.name,
|
|
1230
|
+
moduleAddress: addApiKey_default.address,
|
|
1231
|
+
moduleName: addApiKey_default.name
|
|
1232
|
+
}),
|
|
1233
|
+
function: `${addApiKey_default.address}::${addApiKey_default.name}::add_api_key`,
|
|
1234
|
+
typeArguments: [],
|
|
1235
|
+
functionArguments: [params.userId, params.expiration]
|
|
1219
1236
|
});
|
|
1220
1237
|
}
|
|
1221
1238
|
async removeApiKey(params) {
|
|
@@ -1489,10 +1506,17 @@ var Client = class _Client {
|
|
|
1489
1506
|
return await this.submitSponsoredTransaction(tx, signature);
|
|
1490
1507
|
}
|
|
1491
1508
|
async depositTokenPayload(params) {
|
|
1492
|
-
return (0,
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1509
|
+
return await (0, import_ts_sdk2.generateTransactionPayload)({
|
|
1510
|
+
aptosConfig: this._aptos.config,
|
|
1511
|
+
abi: parseEntryFunctionAbi({
|
|
1512
|
+
moduleAbi: depositToken_default,
|
|
1513
|
+
functionName: depositToken_default.name,
|
|
1514
|
+
moduleAddress: depositToken_default.address,
|
|
1515
|
+
moduleName: depositToken_default.name
|
|
1516
|
+
}),
|
|
1517
|
+
function: `${depositToken_default.address}::${depositToken_default.name}::deposit_token`,
|
|
1518
|
+
typeArguments: [],
|
|
1519
|
+
functionArguments: [params.userId, params.amount, params.tokenAddress]
|
|
1496
1520
|
});
|
|
1497
1521
|
}
|
|
1498
1522
|
async depositToVault(params) {
|
|
@@ -1961,7 +1985,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1961
1985
|
constructor(connection, url, ws, apiKey) {
|
|
1962
1986
|
super(connection, url, ws, apiKey);
|
|
1963
1987
|
}
|
|
1964
|
-
static async create(connection, apiKey, url = "
|
|
1988
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1965
1989
|
let ws = void 0;
|
|
1966
1990
|
if (enableWs) {
|
|
1967
1991
|
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, AccountAuthenticator, SimpleTransaction, MoveModule, EntryFunctionABI } from '@aptos-labs/ts-sdk';
|
|
2
|
+
import { Account, Aptos, MultiAgentTransaction, AccountAuthenticator, SimpleTransaction, 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: MultiAgentTransaction;
|
|
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, AccountAuthenticator, SimpleTransaction, MoveModule, EntryFunctionABI } from '@aptos-labs/ts-sdk';
|
|
2
|
+
import { Account, Aptos, MultiAgentTransaction, AccountAuthenticator, SimpleTransaction, 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: MultiAgentTransaction;
|
|
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,14 @@ import {
|
|
|
3
3
|
AccountAddress,
|
|
4
4
|
ChainId,
|
|
5
5
|
findFirstNonSignerArg,
|
|
6
|
+
generateRawTransaction,
|
|
6
7
|
generateTransactionPayload,
|
|
8
|
+
MultiAgentTransaction,
|
|
7
9
|
parseTypeTag,
|
|
8
10
|
RawTransaction,
|
|
9
11
|
SimpleTransaction
|
|
10
12
|
} from "@aptos-labs/ts-sdk";
|
|
11
|
-
import {
|
|
13
|
+
import { createSurfClient } from "@thalalabs/surf";
|
|
12
14
|
import WebSocket from "isomorphic-ws";
|
|
13
15
|
import { v4 as uuidv4 } from "uuid";
|
|
14
16
|
|
|
@@ -1042,7 +1044,7 @@ var Client = class _Client {
|
|
|
1042
1044
|
this._ws?.send(JSON.stringify(message));
|
|
1043
1045
|
});
|
|
1044
1046
|
}
|
|
1045
|
-
static async create(connection, apiKey, url = "
|
|
1047
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1046
1048
|
return _Client.init(connection, apiKey, url, enableWs);
|
|
1047
1049
|
}
|
|
1048
1050
|
async setApiKey(apiKey) {
|
|
@@ -1063,16 +1065,26 @@ var Client = class _Client {
|
|
|
1063
1065
|
// needs to be signed by user and sent to blockchain
|
|
1064
1066
|
async createUser(params) {
|
|
1065
1067
|
const apiKey = generateApiKey();
|
|
1066
|
-
const payload =
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1068
|
+
const payload = await generateTransactionPayload({
|
|
1069
|
+
aptosConfig: this._aptos.config,
|
|
1070
|
+
abi: parseEntryFunctionAbi({
|
|
1071
|
+
moduleAbi: createUser_default,
|
|
1072
|
+
functionName: createUser_default.name,
|
|
1073
|
+
moduleAddress: createUser_default.address,
|
|
1074
|
+
moduleName: createUser_default.name
|
|
1075
|
+
}),
|
|
1076
|
+
function: `${createUser_default.address}::${createUser_default.name}::create_user`,
|
|
1077
|
+
typeArguments: [],
|
|
1078
|
+
functionArguments: [params.name, params.referralId]
|
|
1075
1079
|
});
|
|
1080
|
+
const tx = new MultiAgentTransaction(
|
|
1081
|
+
await generateRawTransaction({
|
|
1082
|
+
sender: params.sender,
|
|
1083
|
+
aptosConfig: this._aptos.config,
|
|
1084
|
+
payload
|
|
1085
|
+
}),
|
|
1086
|
+
[apiKey.accountAddress]
|
|
1087
|
+
);
|
|
1076
1088
|
const signature = this._aptos.sign({
|
|
1077
1089
|
signer: apiKey,
|
|
1078
1090
|
transaction: tx
|
|
@@ -1161,10 +1173,17 @@ var Client = class _Client {
|
|
|
1161
1173
|
}
|
|
1162
1174
|
// needs to be signed by user and sent to blockchain
|
|
1163
1175
|
async addApiKey(params) {
|
|
1164
|
-
return
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1176
|
+
return await generateTransactionPayload({
|
|
1177
|
+
aptosConfig: this._aptos.config,
|
|
1178
|
+
abi: parseEntryFunctionAbi({
|
|
1179
|
+
moduleAbi: addApiKey_default,
|
|
1180
|
+
functionName: addApiKey_default.name,
|
|
1181
|
+
moduleAddress: addApiKey_default.address,
|
|
1182
|
+
moduleName: addApiKey_default.name
|
|
1183
|
+
}),
|
|
1184
|
+
function: `${addApiKey_default.address}::${addApiKey_default.name}::add_api_key`,
|
|
1185
|
+
typeArguments: [],
|
|
1186
|
+
functionArguments: [params.userId, params.expiration]
|
|
1168
1187
|
});
|
|
1169
1188
|
}
|
|
1170
1189
|
async removeApiKey(params) {
|
|
@@ -1438,10 +1457,17 @@ var Client = class _Client {
|
|
|
1438
1457
|
return await this.submitSponsoredTransaction(tx, signature);
|
|
1439
1458
|
}
|
|
1440
1459
|
async depositTokenPayload(params) {
|
|
1441
|
-
return
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1460
|
+
return await generateTransactionPayload({
|
|
1461
|
+
aptosConfig: this._aptos.config,
|
|
1462
|
+
abi: parseEntryFunctionAbi({
|
|
1463
|
+
moduleAbi: depositToken_default,
|
|
1464
|
+
functionName: depositToken_default.name,
|
|
1465
|
+
moduleAddress: depositToken_default.address,
|
|
1466
|
+
moduleName: depositToken_default.name
|
|
1467
|
+
}),
|
|
1468
|
+
function: `${depositToken_default.address}::${depositToken_default.name}::deposit_token`,
|
|
1469
|
+
typeArguments: [],
|
|
1470
|
+
functionArguments: [params.userId, params.amount, params.tokenAddress]
|
|
1445
1471
|
});
|
|
1446
1472
|
}
|
|
1447
1473
|
async depositToVault(params) {
|
|
@@ -1619,7 +1645,7 @@ function parseEntryFunctionAbi(args) {
|
|
|
1619
1645
|
}
|
|
1620
1646
|
|
|
1621
1647
|
// src/testFaucet.ts
|
|
1622
|
-
import { createEntryPayload
|
|
1648
|
+
import { createEntryPayload } from "@thalalabs/surf";
|
|
1623
1649
|
|
|
1624
1650
|
// generated_types/faucetEntrypoints.ts
|
|
1625
1651
|
var ABI16 = {
|
|
@@ -1910,7 +1936,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1910
1936
|
constructor(connection, url, ws, apiKey) {
|
|
1911
1937
|
super(connection, url, ws, apiKey);
|
|
1912
1938
|
}
|
|
1913
|
-
static async create(connection, apiKey, url = "
|
|
1939
|
+
static async create(connection, apiKey, url = "https://api.dev.nightly.exchange", enableWs = true) {
|
|
1914
1940
|
let ws = void 0;
|
|
1915
1941
|
if (enableWs) {
|
|
1916
1942
|
ws = await client_default.initWebSocket(url);
|
|
@@ -1918,7 +1944,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1918
1944
|
return new _TestFaucet(connection, url, ws, apiKey);
|
|
1919
1945
|
}
|
|
1920
1946
|
initFaucetPayload() {
|
|
1921
|
-
return
|
|
1947
|
+
return createEntryPayload(faucetEntrypoints_default, {
|
|
1922
1948
|
function: "initialize_faucet",
|
|
1923
1949
|
functionArguments: [],
|
|
1924
1950
|
typeArguments: []
|
|
@@ -1939,7 +1965,7 @@ var TestFaucet = class _TestFaucet extends client_default {
|
|
|
1939
1965
|
return await this.submitSponsoredTransaction(tx, signature);
|
|
1940
1966
|
}
|
|
1941
1967
|
mintTokenPayload(receiver, token, amount) {
|
|
1942
|
-
return
|
|
1968
|
+
return createEntryPayload(faucetEntrypoints_default, {
|
|
1943
1969
|
function: "mint_test_token",
|
|
1944
1970
|
functionArguments: [receiver, token, amount],
|
|
1945
1971
|
typeArguments: []
|