Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/account/AbstractedAccount.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sha3_256 } from "@noble/hashes/sha3";
import { AccountAddress } from "../core";
import { AbstractPublicKey, AbstractSignature } from "../core/crypto/abstraction";
import { SigningScheme, HexInput } from "../types";
import { SigningScheme, HexInput, MoveFunctionId } from "../types";
import { Account } from "./Account";
import { AnyRawTransaction } from "../transactions/types";
import {
Expand Down Expand Up @@ -34,15 +34,15 @@ type AbstractedAccountConstructorArgs = {
* const authenticationFunction = `${accountAddress}::permissioned_delegation::authenticate`;
* ```
*/
authenticationFunction: string;
authenticationFunction: MoveFunctionId;
};

export class AbstractedAccount extends Account {
public readonly publicKey: AbstractPublicKey;

readonly accountAddress: AccountAddress;

readonly authenticationFunction: string;
readonly authenticationFunction: MoveFunctionId;

readonly signingScheme = SigningScheme.SingleKey;

Expand Down
8 changes: 4 additions & 4 deletions src/account/DerivableAbstractedAccount.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { sha3_256 } from "@noble/hashes/sha3";
import { Serializer } from "../bcs/serializer";
import { AccountAddress } from "../core/accountAddress";
import { AccountAbstractionMessage, AccountAuthenticatorAbstraction } from "../transactions/authenticator/account";
import { HexInput } from "../types";
import { AccountAuthenticatorAbstraction } from "../transactions/authenticator/account";
import { HexInput, MoveFunctionId } from "../types";
import { isValidFunctionInfo } from "../utils/helpers";
import { AbstractedAccount } from "./AbstractedAccount";
import { generateSigningMessage } from "../transactions/transactionBuilder/signingMessage";
Expand All @@ -25,7 +25,7 @@ type DerivableAbstractedAccountArgs = {
* const authenticationFunction = `${accountAddress}::permissioned_delegation::authenticate`;
* ```
*/
authenticationFunction: string;
authenticationFunction: MoveFunctionId;

/**
* The abstract public key that is used to identify the account.
Expand Down Expand Up @@ -67,7 +67,7 @@ export class DerivableAbstractedAccount extends AbstractedAccount {
* @param accountIdentifier - The account identity
* @returns The account address
*/
static computeAccountAddress(functionInfo: string, accountIdentifier: Uint8Array): Uint8Array {
static computeAccountAddress(functionInfo: MoveFunctionId, accountIdentifier: Uint8Array): Uint8Array {
if (!isValidFunctionInfo(functionInfo)) {
throw new Error(`Invalid authentication function ${functionInfo} passed into DerivableAbstractedAccount`);
}
Expand Down
8 changes: 2 additions & 6 deletions src/account/MultiKeyAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ export class MultiKeyAccount implements Account, KeylessSigner {
* @category Account (On-Chain Model)
*/
async waitForProofFetch(): Promise<void> {
const keylessSigners = this.signers.filter(
(signer) => signer instanceof AbstractKeylessAccount,
) as AbstractKeylessAccount[];
const keylessSigners = this.signers.filter((signer) => signer instanceof AbstractKeylessAccount);
const promises = keylessSigners.map(async (signer) => signer.waitForProofFetch());
await Promise.all(promises);
}
Expand All @@ -216,9 +214,7 @@ export class MultiKeyAccount implements Account, KeylessSigner {
* @category Account (On-Chain Model)
*/
async checkKeylessAccountValidity(aptosConfig: AptosConfig): Promise<void> {
const keylessSigners = this.signers.filter(
(signer) => signer instanceof AbstractKeylessAccount,
) as AbstractKeylessAccount[];
const keylessSigners = this.signers.filter((signer) => signer instanceof AbstractKeylessAccount);
const promises = keylessSigners.map((signer) => signer.checkKeylessAccountValidity(aptosConfig));
await Promise.all(promises);
}
Expand Down
6 changes: 3 additions & 3 deletions src/api/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,15 +835,15 @@ export class Account {
async () => {
try {
const pairedCoinTypeStruct = (
await view({
await view<[{ vec: [MoveStructId] }]>({
aptosConfig: this.config,
payload: { function: "0x1::coin::paired_coin", functionArguments: [faMetadataAddress] },
})
).at(0) as { vec: MoveValue[] };
)[0];

// Check if the Option has a value, and if so, parse the struct
if (pairedCoinTypeStruct.vec.length > 0 && isEncodedStruct(pairedCoinTypeStruct.vec[0])) {
return parseEncodedStruct(pairedCoinTypeStruct.vec[0]) as MoveStructId;
return parseEncodedStruct(pairedCoinTypeStruct.vec[0]);
}
} catch (error) {
/* No paired coin type found */
Expand Down
10 changes: 5 additions & 5 deletions src/api/account/abstraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class AccountAbstraction {
*/
public async addAuthenticationFunctionTransaction(args: {
accountAddress: AccountAddressInput;
authenticationFunction: string;
authenticationFunction: MoveFunctionId;
options?: InputGenerateTransactionOptions;
}) {
const { accountAddress, authenticationFunction, options } = args;
Expand Down Expand Up @@ -67,7 +67,7 @@ export class AccountAbstraction {
*/
public async removeAuthenticationFunctionTransaction(args: {
accountAddress: AccountAddressInput;
authenticationFunction: string;
authenticationFunction: MoveFunctionId;
options?: InputGenerateTransactionOptions;
}) {
const { accountAddress, authenticationFunction, options } = args;
Expand Down Expand Up @@ -166,10 +166,10 @@ export class AccountAbstraction {
*/
public isAccountAbstractionEnabled = async (args: {
accountAddress: AccountAddressInput;
authenticationFunction: string;
authenticationFunction: MoveFunctionId;
}) => {
const functionInfos = await this.getAuthenticationFunction(args);
const { moduleAddress, moduleName, functionName } = getFunctionParts(args.authenticationFunction as MoveFunctionId);
const { moduleAddress, moduleName, functionName } = getFunctionParts(args.authenticationFunction);
return (
functionInfos?.some(
(functionInfo) =>
Expand Down Expand Up @@ -223,7 +223,7 @@ export class AccountAbstraction {
*/
public disableAccountAbstractionTransaction = async (args: {
accountAddress: AccountAddressInput;
authenticationFunction?: string;
authenticationFunction?: MoveFunctionId;
options?: InputGenerateTransactionOptions;
}) => {
const { accountAddress, authenticationFunction, options } = args;
Expand Down
2 changes: 1 addition & 1 deletion src/api/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class Transaction {
* ```
* @group Transaction
*/
async getTransactions(args?: { options?: PaginationArgs }): Promise<TransactionResponse[]> {
async getTransactions(args?: { options?: PaginationArgs }): Promise<CommittedTransactionResponse[]> {
return getTransactions({
aptosConfig: this.config,
...args,
Expand Down
2 changes: 1 addition & 1 deletion src/client/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export async function aptosRequest<Req extends {}, Res extends {}>(
// to support both fullnode and indexer responses,
// check if it is an indexer query, and adjust response.data
if (apiType === AptosApiType.INDEXER) {
const indexerResponse = aptosResponse.data as any;
const indexerResponse = aptosResponse.data as { errors?: string[]; data?: Res };
// Handle Indexer general errors
if (indexerResponse.errors) {
throw new AptosApiError({
Expand Down
8 changes: 4 additions & 4 deletions src/internal/abstraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { getFunctionParts } from "../utils/helpers";
export async function addAuthenticationFunctionTransaction(args: {
aptosConfig: AptosConfig;
sender: AccountAddressInput;
authenticationFunction: string;
authenticationFunction: MoveFunctionId;
options?: InputGenerateTransactionOptions;
}): Promise<SimpleTransaction> {
const { aptosConfig, sender, authenticationFunction, options } = args;
const { moduleAddress, moduleName, functionName } = getFunctionParts(authenticationFunction as MoveFunctionId);
const { moduleAddress, moduleName, functionName } = getFunctionParts(authenticationFunction);
return generateTransaction({
aptosConfig,
sender,
Expand All @@ -38,11 +38,11 @@ export async function addAuthenticationFunctionTransaction(args: {
export async function removeAuthenticationFunctionTransaction(args: {
aptosConfig: AptosConfig;
sender: AccountAddressInput;
authenticationFunction: string;
authenticationFunction: MoveFunctionId;
options?: InputGenerateTransactionOptions;
}) {
const { aptosConfig, sender, authenticationFunction, options } = args;
const { moduleAddress, moduleName, functionName } = getFunctionParts(authenticationFunction as MoveFunctionId);
const { moduleAddress, moduleName, functionName } = getFunctionParts(authenticationFunction);
return generateTransaction({
aptosConfig,
sender,
Expand Down
8 changes: 4 additions & 4 deletions src/internal/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ import { getIndexerLastSuccessVersion, getProcessorStatus } from "./general";
export async function getTransactions(args: {
aptosConfig: AptosConfig;
options?: PaginationArgs;
}): Promise<TransactionResponse[]> {
}): Promise<CommittedTransactionResponse[]> {
const { aptosConfig, options } = args;
return paginateWithCursor<{}, TransactionResponse[]>({
return paginateWithCursor<{}, CommittedTransactionResponse[]>({
aptosConfig,
originMethod: "getTransactions",
path: "transactions",
Expand Down Expand Up @@ -456,12 +456,12 @@ async function fillBlockTransactions(args: {
// Transactions should be filled, but this ensures it
block.transactions = block.transactions ?? [];

const lastTxn = block.transactions[block.transactions.length - 1];
const lastTxn = block.transactions[block.transactions.length - 1] as CommittedTransactionResponse;
const firstVersion = BigInt(block.first_version);
const lastVersion = BigInt(block.last_version);

// Convert the transaction to the type
const curVersion: string | undefined = (lastTxn as any)?.version;
const curVersion: string | undefined = lastTxn.version;
let latestVersion;

// This time, if we don't have any transactions, we will try once with the start of the block
Expand Down
6 changes: 3 additions & 3 deletions src/transactions/authenticator/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class AccountAuthenticatorNoAccountAuthenticator extends AccountAuthentic
* @category Transactions
*/
export class AccountAuthenticatorAbstraction extends AccountAuthenticator {
public readonly functionInfo: string;
public readonly functionInfo: MoveFunctionId;

public readonly signingMessageDigest: Hex;

Expand All @@ -292,7 +292,7 @@ export class AccountAuthenticatorAbstraction extends AccountAuthenticator {
public readonly accountIdentity?: Uint8Array;

constructor(
functionInfo: string,
functionInfo: MoveFunctionId,
signingMessageDigest: HexInput,
abstractionSignature: Uint8Array,
accountIdentity?: Uint8Array,
Expand All @@ -309,7 +309,7 @@ export class AccountAuthenticatorAbstraction extends AccountAuthenticator {

serialize(serializer: Serializer): void {
serializer.serializeU32AsUleb128(AccountAuthenticatorVariant.Abstraction);
const { moduleAddress, moduleName, functionName } = getFunctionParts(this.functionInfo as MoveFunctionId);
const { moduleAddress, moduleName, functionName } = getFunctionParts(this.functionInfo);
AccountAddress.fromString(moduleAddress).serialize(serializer);
serializer.serializeStr(moduleName);
serializer.serializeStr(functionName);
Expand Down
2 changes: 1 addition & 1 deletion src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ export type Block = {
/**
* The transactions in the block in sequential order
*/
transactions?: Array<TransactionResponse>;
transactions?: Array<CommittedTransactionResponse>;
};

// REQUEST TYPES
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/api/transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe("transaction api", () => {
expect(blockData.block_height).toBe(blockHeight.toString());
const length = BigInt(blockData.transactions?.length ?? 0);

const txnVersions = blockData.transactions!.map((txn) => BigInt((txn as any).version));
const txnVersions = blockData.transactions!.map((txn) => BigInt(txn.version));
// Check that every exists
for (let i = 0; i < txnVersions.length - 1; i += 1) {
expect(txnVersions[i]).toBe(txnVersions[i + 1] - 1n);
Expand Down Expand Up @@ -163,7 +163,7 @@ describe("transaction api", () => {
expect(blockData.block_height).toBe(info.block_height.toString());
const length = BigInt(blockData.transactions?.length ?? 0);

const txnVersions = blockData.transactions!.map((txn) => BigInt((txn as any).version));
const txnVersions = blockData.transactions!.map((txn) => BigInt(txn.version));
// Check that every exists
for (let i = 0; i < txnVersions.length - 1; i += 1) {
expect(txnVersions[i]).toBe(txnVersions[i + 1] - 1n);
Expand Down
Loading