Skip to content

Commit d9e1ce6

Browse files
committed
feat: SDK skeleton
1 parent c65364c commit d9e1ce6

19 files changed

+295
-153
lines changed

lib/BaseSDK.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Address } from "algosdk";
2+
export declare abstract class BaseSDK {
3+
abstract client: {
4+
appId: bigint;
5+
appAddress: Address;
6+
};
7+
get appId(): bigint;
8+
get appAddress(): Address;
9+
}

lib/BaseSDK.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export class BaseSDK {
2+
get appId() {
3+
return this.client.appId;
4+
}
5+
get appAddress() {
6+
return this.client.appAddress;
7+
}
8+
}

lib/XGovProposalSDK.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { AlgorandClient } from "@algorandfoundation/algokit-utils";
2+
import { BaseSDK } from "./BaseSDK";
3+
import { ProposalClient } from "./generated/ProposalClient";
4+
export declare class XGovProposalSDK extends BaseSDK {
5+
client: ProposalClient;
6+
algorand: AlgorandClient;
7+
static APP_SPEC: import("@algorandfoundation/algokit-utils/types/app-arc56").Arc56Contract;
8+
constructor({ appId, algorand, }: {
9+
appId: bigint;
10+
algorand: AlgorandClient;
11+
});
12+
}

lib/XGovProposalSDK.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { BaseSDK } from "./BaseSDK";
2+
import { APP_SPEC as PROPOSAL_APP_SPEC, ProposalClient, } from "./generated/ProposalClient";
3+
export class XGovProposalSDK extends BaseSDK {
4+
client;
5+
algorand;
6+
static APP_SPEC = PROPOSAL_APP_SPEC;
7+
constructor({ appId, algorand, }) {
8+
super();
9+
this.algorand = algorand;
10+
this.client = new ProposalClient({ appId, algorand });
11+
}
12+
}

lib/XGovRegistrySDK.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { AlgorandClient } from "@algorandfoundation/algokit-utils";
2+
import { XGovRegistryClient } from "./generated/XGovRegistryClient";
3+
import { BaseSDK } from "./BaseSDK";
4+
export declare class XGovRegistrySDK extends BaseSDK {
5+
client: XGovRegistryClient;
6+
algorand: AlgorandClient;
7+
static APP_SPEC: import("@algorandfoundation/algokit-utils/types/app-arc56").Arc56Contract;
8+
constructor({ appId, algorand, }: {
9+
appId: bigint;
10+
algorand: AlgorandClient;
11+
});
12+
getProposalAppIds(): Promise<bigint[]>;
13+
}

lib/XGovRegistrySDK.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { APP_SPEC as REGISTRY_APP_SPEC, XGovRegistryClient, } from "./generated/XGovRegistryClient";
2+
import { BaseSDK } from "./BaseSDK";
3+
export class XGovRegistrySDK extends BaseSDK {
4+
client;
5+
algorand;
6+
static APP_SPEC = REGISTRY_APP_SPEC;
7+
constructor({ appId, algorand, }) {
8+
super();
9+
this.algorand = algorand;
10+
this.client = new XGovRegistryClient({ appId, algorand });
11+
}
12+
async getProposalAppIds() {
13+
const { createdApps } = await this.algorand.account.getInformation(this.appAddress);
14+
return createdApps?.map(({ id }) => id) || [];
15+
}
16+
}

lib/ProposalClient.d.ts renamed to lib/generated/ProposalClient.d.ts

Lines changed: 58 additions & 59 deletions
Large diffs are not rendered by default.
File renamed without changes.

lib/XGovRegistryClient.d.ts renamed to lib/generated/XGovRegistryClient.d.ts

Lines changed: 77 additions & 78 deletions
Large diffs are not rendered by default.
File renamed without changes.

0 commit comments

Comments
 (0)