Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
b818436
chore: update event log fetching documentation and improve code consi…
mahabubAlahi Apr 7, 2026
356fc49
feat: add getReceipt method to OakContractsClient for fetching transa…
mahabubAlahi Apr 8, 2026
a35bbf8
feat: add encoding and decoding utilities for function data and event…
mahabubAlahi Apr 8, 2026
8174d48
feat: add toSimulationResult function and enhance simulateWithErrorDe…
mahabubAlahi Apr 8, 2026
6c49d87
feat: add contract write preparation utilities with prepareContractWr…
mahabubAlahi Apr 8, 2026
2efe5d4
feat: export additional ABI contracts in index.ts for improved contra…
mahabubAlahi Apr 8, 2026
5f2d63f
feat: enhance simulation methods to return SimulationResult for bette…
mahabubAlahi Apr 8, 2026
19dd0c6
feat: add getReceipt tests and enhance contract simulation utilities …
mahabubAlahi Apr 8, 2026
3790243
docs: update README to include transaction receipt methods and simula…
mahabubAlahi Apr 8, 2026
9425a8d
docs(contracts): slim down README and reflect latest client changes
mahabubAlahi Apr 8, 2026
3f67e07
feat: update simulation utilities to use structured request format an…
mahabubAlahi Apr 8, 2026
a9fd512
fix: update toPreparedTransaction to handle gas estimation correctly
mahabubAlahi Apr 8, 2026
8f6e55f
feat: add scenario-based examples for platform enlistment process
mahabubAlahi Apr 9, 2026
5911b8e
feat: implement all-or-nothing crowdfunding campaign example
mahabubAlahi Apr 9, 2026
cd1865f
feat: implement Keep-What's-Raised crowdfunding campaign example
mahabubAlahi Apr 9, 2026
f699af0
feat: implement e-commerce payment flow examples using Payment Treasury
mahabubAlahi Apr 9, 2026
fdcef46
feat: add event monitoring examples for analytics dashboard
mahabubAlahi Apr 9, 2026
da80227
feat: add error handling and transaction safety examples
mahabubAlahi Apr 9, 2026
f436b90
feat: add advanced patterns examples for contract interactions
mahabubAlahi Apr 9, 2026
4002f7a
feat: add shared client setup for example contracts
mahabubAlahi Apr 9, 2026
dfe5455
feat: add comprehensive README.md for examples for Oak Contracts SDK
mahabubAlahi Apr 9, 2026
b9912c3
feat: enhance treasury implementation examples and documentation
mahabubAlahi Apr 9, 2026
7363d30
fix: update treasury address reference in deployment examples
mahabubAlahi Apr 9, 2026
6316ad3
fix: improve error handling for wallet connection in read-only client…
mahabubAlahi Apr 9, 2026
813bf11
fix: ensure transaction safety for fee disbursement and withdrawal in…
mahabubAlahi Apr 9, 2026
4806726
fix: enhance transaction handling and clarity in treasury examples
mahabubAlahi Apr 9, 2026
4bbb0f5
fix: update example files for clarity and organization
mahabubAlahi Apr 9, 2026
05c14cf
fix: improve treasury address retrieval in deployment examples
mahabubAlahi Apr 9, 2026
52f1f20
refactor: update refund handling for NFT owners in payment treasury e…
mahabubAlahi Apr 9, 2026
a8ab3ab
feat: add type-safe event name constants for contracts
mahabubAlahi Apr 10, 2026
8f8c065
feat: add error name constants for various contracts
mahabubAlahi Apr 10, 2026
1954ffb
feat: add new events and update reads for GlobalParams contract
mahabubAlahi Apr 10, 2026
b0b6f3c
test: add unit tests for new GlobalParams contract events and methods
mahabubAlahi Apr 10, 2026
cb8e8eb
feat: add paused and unpaused events to PaymentTreasury contract
mahabubAlahi Apr 10, 2026
646a629
test: add unit tests for paused and unpaused events in PaymentTreasur…
mahabubAlahi Apr 10, 2026
a3daf39
feat: add PausableCancellable and PledgeNFT related missing events, …
mahabubAlahi Apr 10, 2026
b0cd33b
test: enhance unit tests for contract entities with new methods and e…
mahabubAlahi Apr 10, 2026
c97cd7c
refactor: enhance error handling in global params, item registry, and…
mahabubAlahi Apr 10, 2026
6c014dd
test: add unit tests for additional error cases in parsePaymentTreasu…
mahabubAlahi Apr 10, 2026
85594ca
Merge branch 'feat/contracts-sdk-v2-enhancements' into feat/examples
mahabubAlahi Apr 10, 2026
50e1d9b
refactor: update event handling in treasury deployment examples
mahabubAlahi Apr 10, 2026
3c66e74
refactor: enhance error handling in catch-typed-errors example
mahabubAlahi Apr 10, 2026
9b9c374
fix: improve error handling in createOakContractsClient function
mahabubAlahi Apr 13, 2026
78f4e0a
test: enhance unit tests for getReceipt error handling in createOakCo…
mahabubAlahi Apr 13, 2026
6a51433
refactor: update toSimulationResult function to use ViemSimulateReque…
mahabubAlahi Apr 13, 2026
3232b2d
test: update error-parsing unit tests to use type assertions for addr…
mahabubAlahi Apr 13, 2026
d8c3c7f
test: refactor and add unit tests for prepareContractWrite and toPrep…
mahabubAlahi Apr 13, 2026
6ee94ca
refactor: enhance type safety for contract write options in prepare.ts
mahabubAlahi Apr 13, 2026
3e8c2c7
test: add unit test for gas estimation error handling in prepareContr…
mahabubAlahi Apr 13, 2026
2d61dc6
refactor: update interfaceId type to Bytes4 for supportsInterface met…
mahabubAlahi Apr 13, 2026
69144a5
test: add unit tests for isBytes4 utility function
mahabubAlahi Apr 13, 2026
d7c953f
docs: enhance simulation method documentation in GlobalParamsSimulate…
mahabubAlahi Apr 13, 2026
d06f512
docs: clarify on-chain callable functions in CAMPAIGN_INFO_ABI
mahabubAlahi Apr 13, 2026
299437e
docs: add comments to clarify type casting for contract read functions
mahabubAlahi Apr 13, 2026
9d02df7
docs: enhance client configuration section in README
mahabubAlahi Apr 13, 2026
f9e2b13
docs: enhance examples with multi-token ERC-20 support details
mahabubAlahi Apr 15, 2026
04e9a44
docs: add use-case-driven integration guides for Oak Contracts SDK
mahabubAlahi Apr 15, 2026
bfb8e08
docs: update examples for partial and final withdrawal processes
mahabubAlahi Apr 15, 2026
3d42e6a
refactor: improve token ID handling in refund examples
mahabubAlahi Apr 15, 2026
bd0ef4a
docs: update refund models in healthcare, marketplace, and prepayment…
mahabubAlahi Apr 15, 2026
b7a8974
chore: exclude example and script files from coverage collection
mahabubAlahi Apr 15, 2026
33c8315
docs: clarify payment flows in campaign payment treasury examples
mahabubAlahi Apr 17, 2026
6eaca09
docs: clarify payment flows in automotive prepayment use case
mahabubAlahi Apr 17, 2026
6470b98
docs: update marketplace use case documentation for clarity
mahabubAlahi Apr 17, 2026
c37bbb2
docs: update campaign and community project documentation for clarity
mahabubAlahi Apr 17, 2026
59858d3
docs: update refund process examples to include NFT approval requirem…
mahabubAlahi Apr 17, 2026
c934f8a
docs: enhance refund process documentation with NFT approval steps
mahabubAlahi Apr 17, 2026
2d02bbf
fix: update privateKey handling in README example
mahabubAlahi Apr 17, 2026
827c509
docs: enhance use case documentation for clarity and accuracy
mahabubAlahi Apr 17, 2026
9b0eece
refactor: remove unused functions and events from AllOrNothing and Ke…
mahabubAlahi Apr 17, 2026
0296eae
refactor: remove token management functions from KeepWhatsRaised cont…
mahabubAlahi Apr 17, 2026
80c2d1a
refactor: streamline contract tests by removing unused token manageme…
mahabubAlahi Apr 17, 2026
769650b
refactor: remove unused event names from AllOrNothing and KeepWhatsRa…
mahabubAlahi Apr 17, 2026
3183a0f
Merge branch 'feat/contracts-sdk-v2-enhancements' into feat/examples
mahabubAlahi Apr 17, 2026
5de9160
refactor: update NFT handling across campaign examples to use Campaig…
mahabubAlahi Apr 17, 2026
e8848d7
refactor: update refund processes to clarify NFT management through C…
mahabubAlahi Apr 17, 2026
c7678b7
refactor: restructure payment treasury examples for clarity and funct…
mahabubAlahi Apr 17, 2026
d5176b8
refactor: update use case documentation to incorporate CampaignInfo c…
mahabubAlahi Apr 17, 2026
9ec38c5
refactor: enhance treasury registration verification examples
mahabubAlahi Apr 17, 2026
b610793
chore: added changeset
tahseen-ccprotocol Apr 17, 2026
7440165
chore: added changeset
tahseen-ccprotocol Apr 17, 2026
b6547d7
Merge pull request #105 from oak-network/update/events
mahabubAlahi Apr 17, 2026
5a2434a
docs(contracts): align PaymentTreasury use cases and examples with on…
adnanhq Apr 17, 2026
a47eb4f
fix(contracts-sdk): mark changeset as major and add TAbi generic to p…
adnanhq Apr 17, 2026
29c92c5
refactor: enhance treasury registration verification logic
mahabubAlahi Apr 17, 2026
be936dd
docs(README): add examples and use cases sections for SDK guidance
mahabubAlahi Apr 17, 2026
7f887fa
Merge branch 'develop' into feat/contracts-sdk-v2-enhancements
adnanhq Apr 17, 2026
9509b92
fix(contracts): satisfy viem typings for encodeFunctionData in prepar…
adnanhq Apr 17, 2026
f8ffd4a
test(contracts): cover default args branch in prepareContractWrite to…
adnanhq Apr 17, 2026
b08caee
Merge pull request #106 from oak-network/feat/contracts-sdk-v2-enhanc…
mahabubAlahi Apr 17, 2026
fe24b49
Merge branch 'develop' into feat/examples
mahabubAlahi Apr 17, 2026
b47090b
Merge pull request #108 from oak-network/feat/examples
mahabubAlahi Apr 17, 2026
a8ad051
chore: update changeset
mahabubAlahi Apr 17, 2026
e404554
Merge pull request #110 from oak-network/update/changeset
mahabubAlahi Apr 17, 2026
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
5 changes: 5 additions & 0 deletions .changeset/bumpy-games-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@oaknetwork/contracts-sdk": minor
---

Add missing events, reads, errors, type-safe constants, simulation results, transaction preparation, and getReceipt; update event log fetching documentation and improve code consistency
809 changes: 131 additions & 678 deletions packages/contracts/README.md

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions packages/contracts/__tests__/integration/all-or-nothing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ describe("AllOrNothing — reads (may revert on uninitialized implementation)",
it("getPlatformFeePercent", async () => { try { expect(typeof (await aon.getPlatformFeePercent())).toBe("bigint"); } catch { /* implementation revert */ } });
it("paused", async () => { try { expect(typeof (await aon.paused())).toBe("boolean"); } catch { /* implementation revert */ } });
it("cancelled", async () => { try { expect(typeof (await aon.cancelled())).toBe("boolean"); } catch { /* implementation revert */ } });
it("balanceOf", async () => { try { expect(typeof (await aon.balanceOf(ZERO_ADDR))).toBe("bigint"); } catch { /* implementation revert */ } });
it("ownerOf (may revert)", async () => { try { await aon.ownerOf(0n); } catch { /* expected */ } });
it("tokenURI (may revert)", async () => { try { await aon.tokenURI(0n); } catch { /* expected */ } });
it("name", async () => { try { expect(typeof (await aon.name())).toBe("string"); } catch { /* implementation revert */ } });
it("symbol", async () => { try { expect(typeof (await aon.symbol())).toBe("string"); } catch { /* implementation revert */ } });
it("getApproved (may revert)", async () => { try { await aon.getApproved(0n); } catch { /* expected */ } });
it("isApprovedForAll", async () => { try { expect(typeof (await aon.isApprovedForAll(ZERO_ADDR, ZERO_ADDR))).toBe("boolean"); } catch { /* implementation revert */ } });
it("supportsInterface", async () => { try { expect(typeof (await aon.supportsInterface("0x80ac58cd"))).toBe("boolean"); } catch { /* implementation revert */ } });
});

describe("AllOrNothing — writes (may revert)", () => {
Expand All @@ -40,11 +32,6 @@ describe("AllOrNothing — writes (may revert)", () => {
it("claimRefund", async () => { try { await aon.claimRefund(0n); } catch { /* expected */ } });
it("disburseFees", async () => { try { await aon.disburseFees(); } catch { /* expected */ } });
it("withdraw", async () => { try { await aon.withdraw(); } catch { /* expected */ } });
it("burn", async () => { try { await aon.burn(0n); } catch { /* expected */ } });
it("approve", async () => { try { await aon.approve(ZERO_ADDR, 0n); } catch { /* expected */ } });
it("setApprovalForAll", async () => { try { await aon.setApprovalForAll(ZERO_ADDR, true); } catch { /* expected */ } });
it("safeTransferFrom", async () => { try { await aon.safeTransferFrom(ZERO_ADDR, ZERO_ADDR, 0n); } catch { /* expected */ } });
it("transferFrom", async () => { try { await aon.transferFrom(ZERO_ADDR, ZERO_ADDR, 0n); } catch { /* expected */ } });
});

describe("AllOrNothing — simulate (may throw)", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ describe("CampaignInfo — reads (may revert on uninitialized implementation)",
it("paused", async () => {
try { expect(typeof (await ci.paused())).toBe("boolean"); } catch { /* implementation revert */ }
});
it("getApproved (may revert)", async () => { try { await ci.getApproved(0n); } catch { /* expected */ } });
it("isApprovedForAll", async () => {
try { expect(typeof (await ci.isApprovedForAll(ZERO_ADDR, ZERO_ADDR))).toBe("boolean"); } catch { /* implementation revert */ }
});
});

describe("CampaignInfo — writes (may revert)", () => {
Expand All @@ -112,6 +116,8 @@ describe("CampaignInfo — writes (may revert)", () => {
it("unpauseCampaign", async () => { try { await ci.unpauseCampaign(BYTES32_ZERO); } catch { /* expected */ } });
it("cancelCampaign", async () => { try { await ci.cancelCampaign(BYTES32_ZERO); } catch { /* expected */ } });
it("setPlatformInfo", async () => { try { await ci.setPlatformInfo(BYTES32_ZERO, ZERO_ADDR); } catch { /* expected */ } });
it("approve", async () => { try { await ci.approve(ZERO_ADDR, 0n); } catch { /* expected */ } });
it("setApprovalForAll", async () => { try { await ci.setApprovalForAll(ZERO_ADDR, true); } catch { /* expected */ } });
it("transferOwnership", async () => { try { await ci.transferOwnership(ZERO_ADDR); } catch { /* expected */ } });
it("renounceOwnership", async () => { try { await ci.renounceOwnership(); } catch { /* expected */ } });
});
Expand All @@ -124,6 +130,8 @@ describe("CampaignInfo — simulate (may throw)", () => {
it("simulate.mintNFTForPledge", async () => { try { await ci.simulate.mintNFTForPledge(ZERO_ADDR, BYTES32_ZERO, ZERO_ADDR, 100n, 0n, 0n); } catch { /* expected */ } });
it("simulate.pauseCampaign", async () => { try { await ci.simulate.pauseCampaign(BYTES32_ZERO); } catch { /* expected */ } });
it("simulate.cancelCampaign", async () => { try { await ci.simulate.cancelCampaign(BYTES32_ZERO); } catch { /* expected */ } });
it("simulate.approve", async () => { try { await ci.simulate.approve(ZERO_ADDR, 0n); } catch { /* expected */ } });
it("simulate.setApprovalForAll", async () => { try { await ci.simulate.setApprovalForAll(ZERO_ADDR, true); } catch { /* expected */ } });
});

describe("CampaignInfo — events", () => {
Expand Down
12 changes: 0 additions & 12 deletions packages/contracts/__tests__/integration/keep-whats-raised.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ describe("KeepWhatsRaised — reads (may revert on uninitialized implementation)
it("getFeeValue", async () => { try { expect(typeof (await kwr.getFeeValue(BYTES32_ZERO))).toBe("bigint"); } catch { /* implementation revert */ } });
it("paused", async () => { try { expect(typeof (await kwr.paused())).toBe("boolean"); } catch { /* implementation revert */ } });
it("cancelled", async () => { try { expect(typeof (await kwr.cancelled())).toBe("boolean"); } catch { /* implementation revert */ } });
it("balanceOf", async () => { try { expect(typeof (await kwr.balanceOf(ZERO_ADDR))).toBe("bigint"); } catch { /* implementation revert */ } });
it("ownerOf (may revert)", async () => { try { await kwr.ownerOf(0n); } catch { /* expected */ } });
it("tokenURI (may revert)", async () => { try { await kwr.tokenURI(0n); } catch { /* expected */ } });
it("name", async () => { try { expect(typeof (await kwr.name())).toBe("string"); } catch { /* implementation revert */ } });
it("symbol", async () => { try { expect(typeof (await kwr.symbol())).toBe("string"); } catch { /* implementation revert */ } });
it("getApproved (may revert)", async () => { try { await kwr.getApproved(0n); } catch { /* expected */ } });
it("isApprovedForAll", async () => { try { expect(typeof (await kwr.isApprovedForAll(ZERO_ADDR, ZERO_ADDR))).toBe("boolean"); } catch { /* implementation revert */ } });
it("supportsInterface", async () => { try { expect(typeof (await kwr.supportsInterface("0x80ac58cd"))).toBe("boolean"); } catch { /* implementation revert */ } });
});

describe("KeepWhatsRaised — writes (may revert)", () => {
Expand Down Expand Up @@ -62,10 +54,6 @@ describe("KeepWhatsRaised — writes (may revert)", () => {
it("withdraw", async () => { try { await kwr.withdraw(ZERO_ADDR, 0n); } catch { /* expected */ } });
it("updateDeadline", async () => { try { await kwr.updateDeadline(9999999999n); } catch { /* expected */ } });
it("updateGoalAmount", async () => { try { await kwr.updateGoalAmount(1000n); } catch { /* expected */ } });
it("approve", async () => { try { await kwr.approve(ZERO_ADDR, 0n); } catch { /* expected */ } });
it("setApprovalForAll", async () => { try { await kwr.setApprovalForAll(ZERO_ADDR, true); } catch { /* expected */ } });
it("safeTransferFrom", async () => { try { await kwr.safeTransferFrom(ZERO_ADDR, ZERO_ADDR, 0n); } catch { /* expected */ } });
it("transferFrom", async () => { try { await kwr.transferFrom(ZERO_ADDR, ZERO_ADDR, 0n); } catch { /* expected */ } });
});

describe("KeepWhatsRaised — simulate (may throw)", () => {
Expand Down
63 changes: 63 additions & 0 deletions packages/contracts/__tests__/unit/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,58 @@ describe("createOakContractsClient", () => {
expect(results).toEqual([5n, 250n]);
});

it("getReceipt returns receipt for mined transaction", async () => {
const client = createOakContractsClient({
chainId: CHAIN_IDS.CELO_TESTNET_SEPOLIA,
rpcUrl: RPC,
privateKey: PK,
});
const mockReceipt = {
blockNumber: 456n,
gasUsed: 42000n,
logs: [{ topics: ["0xabc"], data: "0xdef" }],
};
(
client.publicClient as unknown as { getTransactionReceipt: jest.Mock }
).getTransactionReceipt = jest.fn().mockResolvedValue(mockReceipt);

const receipt = await client.getReceipt("0xdeadbeef");
expect(receipt).not.toBeNull();
expect(receipt!.blockNumber).toBe(456n);
expect(receipt!.gasUsed).toBe(42000n);
expect(receipt!.logs).toHaveLength(1);
});

it("getReceipt returns null when transaction is not found", async () => {
const client = createOakContractsClient({
chainId: CHAIN_IDS.CELO_TESTNET_SEPOLIA,
rpcUrl: RPC,
privateKey: PK,
});
const notFoundError = new Error("Transaction receipt not found");
notFoundError.name = "TransactionReceiptNotFoundError";
(
client.publicClient as unknown as { getTransactionReceipt: jest.Mock }
).getTransactionReceipt = jest.fn().mockRejectedValue(notFoundError);

const receipt = await client.getReceipt("0xdeadbeef");
expect(receipt).toBeNull();
});

it("getReceipt re-throws non-receipt errors (e.g. network failures)", async () => {
const client = createOakContractsClient({
chainId: CHAIN_IDS.CELO_TESTNET_SEPOLIA,
rpcUrl: RPC,
privateKey: PK,
});
const networkError = new Error("RPC timeout");
(
client.publicClient as unknown as { getTransactionReceipt: jest.Mock }
).getTransactionReceipt = jest.fn().mockRejectedValue(networkError);

await expect(client.getReceipt("0xdeadbeef")).rejects.toThrow("RPC timeout");
});

it("waitForReceipt calls publicClient.waitForTransactionReceipt", async () => {
const client = createOakContractsClient({
chainId: CHAIN_IDS.CELO_TESTNET_SEPOLIA,
Expand Down Expand Up @@ -173,4 +225,15 @@ describe("contracts barrel export", () => {
expect(contractsIndex.createKeepWhatsRaisedEntity).toBeDefined();
expect(contractsIndex.createItemRegistryEntity).toBeDefined();
});

it("re-exports all contract ABIs", () => {
expect(contractsIndex.GLOBAL_PARAMS_ABI).toBeDefined();
expect(contractsIndex.CAMPAIGN_INFO_FACTORY_ABI).toBeDefined();
expect(contractsIndex.CAMPAIGN_INFO_ABI).toBeDefined();
expect(contractsIndex.TREASURY_FACTORY_ABI).toBeDefined();
expect(contractsIndex.PAYMENT_TREASURY_ABI).toBeDefined();
expect(contractsIndex.ALL_OR_NOTHING_ABI).toBeDefined();
expect(contractsIndex.KEEP_WHATS_RAISED_ABI).toBeDefined();
expect(contractsIndex.ITEM_REGISTRY_ABI).toBeDefined();
});
});
Loading
Loading