Comparing version 0.0.19 to 0.0.20
@@ -73,4 +73,5 @@ import { AxiosRequestConfig, AxiosResponse } from "axios"; | ||
waitForTransaction(txnHash: Types.HexEncodedBytes): Promise<void>; | ||
getLedgerInfo(params?: RequestParams): Promise<Types.LedgerInfo>; | ||
getTableItem(handle: string, data: Types.TableItemRequest, params?: RequestParams): Promise<any>; | ||
} | ||
//# sourceMappingURL=aptos_client.d.ts.map |
@@ -107,4 +107,4 @@ "use strict"; | ||
return Object.assign({ sender: senderAddress.hex(), sequence_number: account.sequence_number, max_gas_amount: "1000", gas_unit_price: "1", gas_currency_code: "XUS", | ||
// Unix timestamp, in seconds + 10 minutes | ||
expiration_timestamp_secs: (Math.floor(Date.now() / 1000) + 600).toString(), payload }, (options || {})); | ||
// Unix timestamp, in seconds + 10 seconds | ||
expiration_timestamp_secs: (Math.floor(Date.now() / 1000) + 10).toString(), payload }, (options || {})); | ||
}); | ||
@@ -198,2 +198,8 @@ } | ||
} | ||
getLedgerInfo(params = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const result = yield this.client.request(Object.assign({ path: "/", method: "GET", format: "json" }, params)); | ||
return result.data; | ||
}); | ||
} | ||
getTableItem(handle, data, params) { | ||
@@ -200,0 +206,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -36,2 +36,8 @@ "use strict"; | ||
})); | ||
test("gets ledger info", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const client = new aptos_client_1.AptosClient(util_test_1.NODE_URL); | ||
const ledgerInfo = yield client.getLedgerInfo(); | ||
expect(ledgerInfo.chain_id).toBeGreaterThan(1); | ||
expect(parseInt(ledgerInfo.ledger_version, 10)).toBeGreaterThan(0); | ||
})); | ||
test("gets account modules", () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -38,0 +44,0 @@ const client = new aptos_client_1.AptosClient(util_test_1.NODE_URL); |
@@ -91,8 +91,3 @@ "use strict"; | ||
type_arguments: [], | ||
arguments: [ | ||
sender, | ||
creator, | ||
Buffer.from(collectionName).toString("hex"), | ||
Buffer.from(name).toString("hex"), | ||
], | ||
arguments: [sender, creator, Buffer.from(collectionName).toString("hex"), Buffer.from(name).toString("hex")], | ||
}; | ||
@@ -110,8 +105,3 @@ const transactionHash = yield this.submitTransactionHelper(account, payload); | ||
type_arguments: [], | ||
arguments: [ | ||
receiver, | ||
creator, | ||
Buffer.from(collectionName).toString("hex"), | ||
Buffer.from(name).toString("hex"), | ||
], | ||
arguments: [receiver, creator, Buffer.from(collectionName).toString("hex"), Buffer.from(name).toString("hex")], | ||
}; | ||
@@ -118,0 +108,0 @@ const transactionHash = yield this.submitTransactionHelper(account, payload); |
@@ -56,3 +56,3 @@ { | ||
}, | ||
"version": "0.0.19" | ||
"version": "0.0.20" | ||
} |
@@ -33,2 +33,9 @@ import { AptosClient, raiseForStatus } from "./aptos_client"; | ||
test("gets ledger info", async () => { | ||
const client = new AptosClient(NODE_URL); | ||
const ledgerInfo = await client.getLedgerInfo(); | ||
expect(ledgerInfo.chain_id).toBeGreaterThan(1); | ||
expect(parseInt(ledgerInfo.ledger_version, 10)).toBeGreaterThan(0); | ||
}); | ||
test("gets account modules", async () => { | ||
@@ -35,0 +42,0 @@ const client = new AptosClient(NODE_URL); |
@@ -11,2 +11,3 @@ import { AxiosRequestConfig, AxiosResponse } from "axios"; | ||
import { Tables } from "./api/Tables"; | ||
import { Address, AptosError, LedgerVersion, MoveModule } from "./api/data-contracts"; | ||
@@ -153,4 +154,4 @@ export class RequestError extends Error { | ||
gas_currency_code: "XUS", | ||
// Unix timestamp, in seconds + 10 minutes | ||
expiration_timestamp_secs: (Math.floor(Date.now() / 1000) + 600).toString(), | ||
// Unix timestamp, in seconds + 10 seconds | ||
expiration_timestamp_secs: (Math.floor(Date.now() / 1000) + 10).toString(), | ||
payload, | ||
@@ -213,5 +214,3 @@ ...(options || {}), | ||
/** Submits a signed transaction to the blockchain. */ | ||
async submitTransaction( | ||
signedTxnRequest: Types.SubmitTransactionRequest, | ||
): Promise<Types.PendingTransaction> { | ||
async submitTransaction(signedTxnRequest: Types.SubmitTransactionRequest): Promise<Types.PendingTransaction> { | ||
const response = await this.transactions.submitTransaction(signedTxnRequest); | ||
@@ -258,10 +257,16 @@ raiseForStatus(202, response, signedTxnRequest); | ||
async getLedgerInfo(params: RequestParams = {}): Promise<Types.LedgerInfo> { | ||
const result = await this.client.request<Types.LedgerInfo, AptosError>({ | ||
path: "/", | ||
method: "GET", | ||
format: "json", | ||
...params, | ||
}); | ||
return result.data; | ||
} | ||
async getTableItem(handle: string, data: Types.TableItemRequest, params?: RequestParams): Promise<any> { | ||
const tableItem = await this.tables.getTableItem( | ||
handle, | ||
data, | ||
params, | ||
); | ||
const tableItem = await this.tables.getTableItem(handle, data, params); | ||
return tableItem; | ||
} | ||
} |
@@ -107,8 +107,3 @@ import { AptosAccount } from "./aptos_account"; | ||
type_arguments: [], | ||
arguments: [ | ||
sender, | ||
creator, | ||
Buffer.from(collectionName).toString("hex"), | ||
Buffer.from(name).toString("hex"), | ||
], | ||
arguments: [sender, creator, Buffer.from(collectionName).toString("hex"), Buffer.from(name).toString("hex")], | ||
}; | ||
@@ -131,8 +126,3 @@ const transactionHash = await this.submitTransactionHelper(account, payload); | ||
type_arguments: [], | ||
arguments: [ | ||
receiver, | ||
creator, | ||
Buffer.from(collectionName).toString("hex"), | ||
Buffer.from(name).toString("hex"), | ||
], | ||
arguments: [receiver, creator, Buffer.from(collectionName).toString("hex"), Buffer.from(name).toString("hex")], | ||
}; | ||
@@ -143,6 +133,3 @@ const transactionHash = await this.submitTransactionHelper(account, payload); | ||
async getCollectionData( | ||
creator: MaybeHexString, | ||
collectionName: string, | ||
): Promise<any> { | ||
async getCollectionData(creator: MaybeHexString, collectionName: string): Promise<any> { | ||
const resources = await this.aptosClient.getAccountResources(creator); | ||
@@ -157,6 +144,3 @@ const accountResource: { type: string; data: any } = resources.find((r) => r.type === "0x1::Token::Collections"); | ||
// eslint-disable-next-line no-unused-vars | ||
const collectionTable = await this.aptosClient.getTableItem( | ||
handle, | ||
getCollectionTableItemRequest, | ||
); | ||
const collectionTable = await this.aptosClient.getTableItem(handle, getCollectionTableItemRequest); | ||
return collectionTable; | ||
@@ -167,3 +151,3 @@ } | ||
async getTokenData(creator: MaybeHexString, collectionName: string, tokenName: string): Promise<number> { | ||
const collection: { type: string, data: any } = await this.aptosClient.getAccountResource( | ||
const collection: { type: string; data: any } = await this.aptosClient.getAccountResource( | ||
creator, | ||
@@ -185,6 +169,3 @@ "0x1::Token::Collections", | ||
const tableItem = await this.aptosClient.getTableItem( | ||
handle, | ||
getTokenTableItemRequest, | ||
); | ||
const tableItem = await this.aptosClient.getTableItem(handle, getTokenTableItemRequest); | ||
return tableItem; | ||
@@ -195,3 +176,3 @@ } | ||
async getTokenBalance(creator: MaybeHexString, collectionName: string, tokenName: string): Promise<number> { | ||
const tokenStore: { type: string, data: any } = await this.aptosClient.getAccountResource( | ||
const tokenStore: { type: string; data: any } = await this.aptosClient.getAccountResource( | ||
creator, | ||
@@ -213,8 +194,5 @@ "0x1::Token::TokenStore", | ||
const tableItem = await this.aptosClient.getTableItem( | ||
handle, | ||
getTokenTableItemRequest, | ||
); | ||
const tableItem = await this.aptosClient.getTableItem(handle, getTokenTableItemRequest); | ||
return tableItem; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
284988
5065