Skip to content

Commit da804af

Browse files
fix pre commit
1 parent ddbb630 commit da804af

88 files changed

Lines changed: 20928 additions & 2141 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

soroban-client/__tests__/lib/tokenbound-sdk.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,23 @@ describe("tokenbound sdk", () => {
1010
"eventManager",
1111
"ticketFactory",
1212
"ticketNft",
13+
"poapNft",
1314
"tbaRegistry",
1415
"tbaAccount",
1516
]);
1617

1718
expect(
1819
GENERATED_CONTRACT_SPECS.eventManager.methods.some(
19-
(method) => method.name === "create_event"
20-
)
20+
(method) => method.name === "create_event",
21+
),
2122
).toBe(true);
2223
});
2324

2425
it("decodes mapped contract errors", () => {
25-
const decoded = decodeContractError("eventManager", "HostError: Error(Contract, #5)");
26+
const decoded = decodeContractError(
27+
"eventManager",
28+
"HostError: Error(Contract, #5)",
29+
);
2630
expect(decoded).not.toBeNull();
2731
expect(decoded?.name).toBe("InvalidStartDate");
2832
});
@@ -33,7 +37,8 @@ describe("tokenbound sdk", () => {
3337
sorobanRpcUrl: "https://soroban-testnet.stellar.org",
3438
networkPassphrase: "Test SDF Network ; September 2015",
3539
contracts: {
36-
eventManager: "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
40+
eventManager:
41+
"CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM",
3742
},
3843
});
3944

soroban-client/jest.config.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import type { Config } from 'jest';
2-
import nextJest from 'next/jest.js';
1+
import type { Config } from "jest";
2+
import nextJest from "next/jest.js";
33

44
const createJestConfig = nextJest({
55
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
6-
dir: './',
6+
dir: "./",
77
});
88

99
// Add any custom config to be passed to Jest
1010
const config: Config = {
11-
coverageProvider: 'v8',
12-
testEnvironment: 'jsdom',
13-
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
11+
coverageProvider: "v8",
12+
testEnvironment: "jsdom",
13+
setupFiles: ["<rootDir>/jest.polyfills.ts"],
14+
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
1415
collectCoverage: false,
15-
coverageDirectory: '<rootDir>/coverage',
16-
coverageReporters: ['text-summary', 'lcov', 'json-summary'],
16+
coverageDirectory: "<rootDir>/coverage",
17+
coverageReporters: ["text-summary", "lcov", "json-summary"],
1718
coverageThreshold: {
1819
global: {
1920
branches: 70,
@@ -23,8 +24,8 @@ const config: Config = {
2324
},
2425
},
2526
moduleNameMapper: {
26-
// Handle module aliases
27-
'^@/(.*)$': '<rootDir>/$1',
27+
"^@/(.*)$": "<rootDir>/$1",
28+
"^next-intl$": "<rootDir>/test/mocks/next-intl.ts",
2829
},
2930
// Add more setup options before each test is run
3031
// setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],

soroban-client/jest.polyfills.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Runs before any test file is loaded (via setupFiles).
3+
* stellar-sdk expects TextEncoder/TextDecoder; ensure they exist before imports run.
4+
*/
5+
import { TextDecoder, TextEncoder } from "node:util";
6+
7+
if (typeof globalThis.TextEncoder === "undefined") {
8+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9+
(globalThis as any).TextEncoder = TextEncoder;
10+
}
11+
if (typeof globalThis.TextDecoder === "undefined") {
12+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13+
(globalThis as any).TextDecoder = TextDecoder;
14+
}

soroban-client/package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

soroban-client/sdk/scripts/generate-contract-types.mjs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@ import fs from "node:fs";
22
import path from "node:path";
33

44
const repoRoot = path.resolve(process.cwd());
5-
const contractRoot = path.resolve(repoRoot, "..", "soroban-contract", "contracts");
6-
const outputFile = path.resolve(repoRoot, "sdk", "src", "generated", "contracts.ts");
5+
const contractRoot = path.resolve(
6+
repoRoot,
7+
"..",
8+
"soroban-contract",
9+
"contracts",
10+
);
11+
const outputFile = path.resolve(
12+
repoRoot,
13+
"sdk",
14+
"src",
15+
"generated",
16+
"contracts.ts",
17+
);
718

819
const CONTRACT_FILES = [
920
["eventManager", "event_manager/src/lib.rs"],
1021
["ticketFactory", "ticket_factory/src/lib.rs"],
1122
["ticketNft", "ticket_nft/src/lib.rs"],
23+
["poapNft", "poap_nft/src/lib.rs"],
1224
["tbaRegistry", "tba_registry/src/lib.rs"],
1325
["tbaAccount", "tba_account/src/lib.rs"],
1426
];
@@ -21,7 +33,8 @@ function normalizeType(rustType) {
2133
}
2234

2335
function parseMethods(source) {
24-
const methodRegex = /pub fn ([a-zA-Z0-9_]+)\(([\s\S]*?)\)\s*(?:->\s*([^{]+))?\s*\{/g;
36+
const methodRegex =
37+
/pub fn ([a-zA-Z0-9_]+)\(([\s\S]*?)\)\s*(?:->\s*([^{]+))?\s*\{/g;
2538
const methods = [];
2639
for (const match of source.matchAll(methodRegex)) {
2740
const [, name, rawArgs, rawReturn] = match;
@@ -45,6 +58,11 @@ function parseMethods(source) {
4558
name === "owner_of" ||
4659
name === "balance_of" ||
4760
name === "is_valid" ||
61+
name === "token_metadata" ||
62+
name === "has_claimed" ||
63+
name === "get_minter" ||
64+
name === "is_attendance_marked" ||
65+
name === "is_poap_distributed" ||
4866
name === "token" ||
4967
name === "token_contract" ||
5068
name === "token_id" ||
@@ -84,7 +102,7 @@ const specs = Object.fromEntries(
84102
errors: parseErrors(source),
85103
},
86104
];
87-
})
105+
}),
88106
);
89107

90108
const content = `/* eslint-disable */
@@ -94,6 +112,7 @@ export type GeneratedContractName =
94112
| "eventManager"
95113
| "ticketFactory"
96114
| "ticketNft"
115+
| "poapNft"
97116
| "tbaRegistry"
98117
| "tbaAccount";
99118

0 commit comments

Comments
 (0)