Skip to content
Merged
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
4 changes: 2 additions & 2 deletions projects/abel-cli/.env.local
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MNEMONIC=pattern orphan fantasy thunder card scan skull tragic bread agree build warfare chicken bottom leave quiz fringe armed dizzy twice endorse champion drill abstract replace
ABEL_APP_ID=1002
MNEMONIC=tumble armed pony permit tree choose portion matter hold equal stamp rural kangaroo infant nothing scale paddle twist gravity lonely retreat annual gallery able gravity
ABEL_APP_ID=18154
ALGOD_PORT=4001
ALGOD_HOST=http://127.0.0.1
ALGOD_TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Expand Down
28 changes: 19 additions & 9 deletions projects/abel-cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/abel-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"abel-sdk": "=0.1.0",
"abel-sdk": "../abel-sdk-v2",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

"dotenv": "^16.4.7",
"p-map": "^7.0.3",
"zod": "^3.24.2"
Expand Down
32 changes: 19 additions & 13 deletions projects/abel-sdk-v2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,31 @@ import { BoxName } from "@algorandfoundation/algokit-utils/types/app";
import { decodeAddress, decodeUint64, encodeAddress, encodeUint64, makeEmptyTransactionSigner } from "algosdk";
import pMap from "p-map";
import {
AssetFull,
AssetFullFromTuple,
AssetLabelingClient,
AssetLabelingFactory,
AssetMicro,
AssetMicroFromTuple,
AssetMicroLabels,
AssetMicroLabelsFromTuple,
AssetSmall,
AssetSmallFromTuple,
AssetText,
AssetTextFromTuple,
AssetTextLabels,
AssetTextLabelsFromTuple,
AssetTiny,
AssetTinyFromTuple,
AssetTinyLabels,
AssetTinyLabelsFromTuple,
LabelDescriptorFromTuple as LabelDescriptorBoxValueFromTuple,
} from "./generated/abel-contract-client.js";
import { AnyFn, FirstArgument, LabelDescriptor, QueryReturn } from "./types.js";
import {
AnyFn,
AssetFull,
AssetMicro,
AssetMicroLabels,
AssetSmall,
AssetText,
AssetTextLabels,
AssetTiny,
AssetTinyLabels,
LabelDescriptor,
QueryReturn,
} from "./types.js";
import { chunk, encodeUint64Arr, isNullish, mergeMapsArr, wrapErrors } from "./util.js";

export * from "./types.js";
Expand Down Expand Up @@ -492,10 +496,12 @@ export class AbelSDK {
parseLogsAs<T extends AnyFn>(logs: Uint8Array[], tupleParser: T, abiDecodingMethodName: string): ReturnType<T>[] {
const decodingMethod = this.readClient.appClient.getABIMethod(abiDecodingMethodName);
const parsed = logs.map((logValue) =>
tupleParser(
// @ts-ignore TODO fixable?
decodingMethod.returns.type.decode(logValue)
)
logValue.length
? tupleParser(
// @ts-ignore TODO fixable?
decodingMethod.returns.type.decode(logValue)
)
: { deleted: true }
);
return parsed;
}
Expand Down
25 changes: 21 additions & 4 deletions projects/abel-sdk-v2/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { ABIReturn } from "@algorandfoundation/algokit-utils/types/app";
import { Transaction } from "algosdk";
import { PendingTransactionResponse } from "algosdk/dist/types/client/v2/algod/models/types.js";
import { LabelDescriptor as LabelDescriptorBoxValue, AssetMicro as AssetMicroValue } from "./generated/abel-contract-client.js";
import {
LabelDescriptor as LabelDescriptorBoxValue,
AssetMicro as AssetMicroValue,
AssetMicroLabels as AssetMicroLabelsValue,
AssetTiny as AssetTinyValue,
AssetTinyLabels as AssetTinyLabelsValue,
AssetText as AssetTextValue,
AssetTextLabels as AssetTextLabelsValue,
AssetSmall as AssetSmallValue,
AssetFull as AssetFullValue,
} from "./generated/abel-contract-client.js";

export interface LabelDescriptor extends LabelDescriptorBoxValue {
id: string;
Expand All @@ -17,8 +27,15 @@ export interface QueryReturn {
transactions: Transaction[];
}

export interface AssetMicro extends AssetMicroValue {
id: bigint;
}
export type DeletedAsset = { id: bigint; deleted: true };

export type AssetMicro = (AssetMicroValue & { id: bigint }) | DeletedAsset;
export type AssetMicroLabels = (AssetMicroLabelsValue & { id: bigint }) | DeletedAsset;
export type AssetTiny = (AssetTinyValue & { id: bigint }) | DeletedAsset;
export type AssetTinyLabels = (AssetTinyLabelsValue & { id: bigint }) | DeletedAsset;
export type AssetText = (AssetTextValue & { id: bigint }) | DeletedAsset;
export type AssetTextLabels = (AssetTextLabelsValue & { id: bigint }) | DeletedAsset;
export type AssetSmall = (AssetSmallValue & { id: bigint }) | DeletedAsset;
export type AssetFull = (AssetFullValue & { id: bigint }) | DeletedAsset;

export type FirstArgument<T extends (...args: any[]) => any> = T extends (arg1: infer U, ...args: any[]) => any ? U : never;

Large diffs are not rendered by default.

Loading