diff --git a/.env.example b/.env.example index 50e04a86..6f76f3da 100644 --- a/.env.example +++ b/.env.example @@ -30,4 +30,9 @@ SENTRY_DSN="" SENTRY_ORG="" SENTRY_PROJECT="boundless-next" SENTRY_AUTH_TOKEN="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" -NODE_ENV="dev" \ No newline at end of file +NODE_ENV="dev" +# Soroban contract addresses (testnet defaults are pre-filled; override for mainnet) +NEXT_PUBLIC_BOUNTY_REGISTRY_CONTRACT_ID="CBWXIV3DERH4GKADOTEEI2QADGZAMMJT4T2B5LFVZULGHEP5BACK2TLY" +NEXT_PUBLIC_CORE_ESCROW_CONTRACT_ID="CA3VZVIMGLVG5EJF2ACB3LPMGQ6PID4TJTB3D2B3L6JIZRIS7NQPVPHN" +NEXT_PUBLIC_REPUTATION_REGISTRY_CONTRACT_ID="CBVQEDH4T5KOJQSESL2HEFI2YZWXPSZQ5TASKRNWAVZFIWAKEU74RFF4" +NEXT_PUBLIC_PROJECT_REGISTRY_CONTRACT_ID="CCG4QM2GZKBN7GBRAE3PFNE3GM2B6QRS7FOKLHGV2FT2HHETIS7JUVYT" \ No newline at end of file diff --git a/lib/contracts/bounty-registry/.gitignore b/lib/contracts/bounty-registry/.gitignore new file mode 100644 index 00000000..e1e671ac --- /dev/null +++ b/lib/contracts/bounty-registry/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +out/ + +dist/ diff --git a/lib/contracts/bounty-registry/README.md b/lib/contracts/bounty-registry/README.md new file mode 100644 index 00000000..e2545b29 --- /dev/null +++ b/lib/contracts/bounty-registry/README.md @@ -0,0 +1,54 @@ +# bounty-registry JS + +JS library for interacting with [Soroban](https://soroban.stellar.org/) smart contract `bounty-registry` via Soroban RPC. + +This library was automatically generated by Soroban CLI using a command similar to: + +```bash +soroban contract bindings ts \ + --rpc-url https://soroban-testnet.stellar.org:443 \ + --network-passphrase "Test SDF Network ; September 2015" \ + --contract-id CBWXIV3DERH4GKADOTEEI2QADGZAMMJT4T2B5LFVZULGHEP5BACK2TLY \ + --output-dir ./path/to/bounty-registry +``` + +The network passphrase and contract ID are exported from [index.ts](./src/index.ts) in the `networks` constant. If you are the one who generated this library and you know that this contract is also deployed to other networks, feel free to update `networks` with other valid options. This will help your contract consumers use this library more easily. + +# To publish or not to publish + +This library is suitable for publishing to NPM. You can publish it to NPM using the `npm publish` command. + +But you don't need to publish this library to NPM to use it. You can add it to your project's `package.json` using a file path: + +```json +"dependencies": { + "bounty-registry": "./path/to/this/folder" +} +``` + +However, we've actually encountered [frustration](https://github.com/stellar/soroban-example-dapp/pull/117#discussion_r1232873560) using local libraries with NPM in this way. Though it seems a bit messy, we suggest generating the library directly to your `node_modules` folder automatically after each install by using a `postinstall` script. We've had the least trouble with this approach. NPM will automatically remove what it sees as erroneous directories during the `install` step, and then regenerate them when it gets to your `postinstall` step, which will keep the library up-to-date with your contract. + +```json +"scripts": { + "postinstall": "soroban contract bindings ts --rpc-url https://soroban-testnet.stellar.org:443 --network-passphrase \"Test SDF Network ; September 2015\" --id CBWXIV3DERH4GKADOTEEI2QADGZAMMJT4T2B5LFVZULGHEP5BACK2TLY --name bounty-registry" +} +``` + +Obviously you need to adjust the above command based on the actual command you used to generate the library. + +# Use it + +Now that you have your library up-to-date and added to your project, you can import it in a file and see inline documentation for all of its exported methods: + +```js +import { Contract, networks } from "bounty-registry" + +const contract = new Contract({ + ...networks.testnet, // for example; check which networks this library exports + rpcUrl: '...', // use your own, or find one for testing at https://soroban.stellar.org/docs/reference/rpc#public-rpc-providers +}) + +contract.| +``` + +As long as your editor is configured to show JavaScript/TypeScript documentation, you can pause your typing at that `|` to get a list of all exports and inline-documentation for each. It exports a separate [async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function for each method in the smart contract, with documentation for each generated from the comments the contract's author included in the original source code. diff --git a/lib/contracts/bounty-registry/package.json b/lib/contracts/bounty-registry/package.json new file mode 100644 index 00000000..73aafca6 --- /dev/null +++ b/lib/contracts/bounty-registry/package.json @@ -0,0 +1,17 @@ +{ + "version": "0.0.0", + "name": "bounty-registry", + "type": "module", + "exports": "./dist/index.js", + "typings": "dist/index.d.ts", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@stellar/stellar-sdk": "^14.6.1", + "buffer": "^6.0.3" + }, + "devDependencies": { + "typescript": "^5.6.2" + } +} diff --git a/lib/contracts/bounty-registry/src/index.ts b/lib/contracts/bounty-registry/src/index.ts new file mode 100644 index 00000000..233a8976 --- /dev/null +++ b/lib/contracts/bounty-registry/src/index.ts @@ -0,0 +1,482 @@ +import { Buffer } from 'buffer'; +import { Address } from '@stellar/stellar-sdk'; +import { + AssembledTransaction, + Client as ContractClient, + ClientOptions as ContractClientOptions, + MethodOptions, + Result, + Spec as ContractSpec, +} from '@stellar/stellar-sdk/contract'; +import type { + u32, + i32, + u64, + i64, + u128, + i128, + u256, + i256, + Option, +} from '@stellar/stellar-sdk/contract'; +export * from '@stellar/stellar-sdk'; +export * as contract from '@stellar/stellar-sdk/contract'; +export * as rpc from '@stellar/stellar-sdk/rpc'; + +if (typeof window !== 'undefined') { + //@ts-ignore Buffer exists + window.Buffer = window.Buffer || Buffer; +} + +export const networks = { + testnet: { + networkPassphrase: 'Test SDF Network ; September 2015', + contractId: 'CBWXIV3DERH4GKADOTEEI2QADGZAMMJT4T2B5LFVZULGHEP5BACK2TLY', + }, +} as const; + +export const BountyError = { + 700: { message: 'AlreadyInitialized' }, + 701: { message: 'NotInitialized' }, + 702: { message: 'NotAuthorized' }, + 703: { message: 'BountyNotFound' }, + 704: { message: 'BountyNotOpen' }, + 705: { message: 'DeadlinePassed' }, + 706: { message: 'AlreadyApplied' }, + 707: { message: 'ApplicationNotFound' }, + 708: { message: 'ApplicationNotPending' }, + 709: { message: 'InvalidRating' }, + 710: { message: 'NoEscrowPool' }, + 711: { message: 'AmountNotPositive' }, + 712: { message: 'NotCreator' }, + 713: { message: 'NotAssignee' }, + 714: { message: 'NotInProgress' }, + 715: { message: 'NotReviewable' }, + 716: { message: 'InvalidSubType' }, + 717: { message: 'AlreadyClaimed' }, + 718: { message: 'InsufficientCredits' }, + 719: { message: 'BountyNotCompleted' }, + 720: { message: 'InvalidSplitShares' }, + 721: { message: 'NotContestType' }, + 722: { message: 'NotSplitType' }, + 723: { message: 'SlotNotFound' }, + 724: { message: 'CannotCancel' }, + 725: { message: 'NotFCFSType' }, + 726: { message: 'AutoReleaseNotReady' }, +}; + +export interface Bounty { + amount: i128; + asset: string; + assignee: Option; + bounty_type: BountyType; + category: ActivityCategory; + created_at: u64; + creator: string; + deadline: u64; + escrow_pool_id: Buffer; + id: u64; + metadata_cid: string; + status: BountyStatus; + title: string; + winner_count: u32; +} + +export type BountyType = + | { tag: 'FCFS'; values: void } + | { tag: 'Application'; values: void } + | { tag: 'Contest'; values: void } + | { tag: 'Split'; values: void }; + +export interface Application { + applicant: string; + bounty_id: u64; + proposal: string; + status: ApplicationStatus; + submitted_at: u64; +} + +export type BountyStatus = + | { tag: 'Open'; values: void } + | { tag: 'InProgress'; values: void } + | { tag: 'InReview'; values: void } + | { tag: 'Completed'; values: void } + | { tag: 'Cancelled'; values: void }; + +export type BountyDataKey = + | { tag: 'Admin'; values: void } + | { tag: 'CoreEscrow'; values: void } + | { tag: 'ReputationRegistry'; values: void } + | { tag: 'BountyCount'; values: void } + | { tag: 'Bounty'; values: readonly [u64] } + | { tag: 'Application'; values: readonly [u64, string] } + | { tag: 'ApplicantCount'; values: readonly [u64] } + | { tag: 'Applicant'; values: readonly [u64, u32] } + | { tag: 'SplitRecipient'; values: readonly [u64, u32] }; + +export type ApplicationStatus = + | { tag: 'Pending'; values: void } + | { tag: 'Accepted'; values: void } + | { tag: 'Rejected'; values: void }; + +/** + * Granular sub-type for fee rate lookup and audit trail. + */ +export type SubType = + | { tag: 'BountyFCFS'; values: void } + | { tag: 'BountyApplication'; values: void } + | { tag: 'BountyContest'; values: void } + | { tag: 'BountySplit'; values: void } + | { tag: 'CrowdfundPledge'; values: void } + | { tag: 'GrantMilestone'; values: void } + | { tag: 'GrantRetrospective'; values: void } + | { tag: 'GrantQFMatchingPool'; values: void } + | { tag: 'HackathonMain'; values: void } + | { tag: 'HackathonTrack'; values: void }; + +/** + * Identifies which platform module owns a resource (escrow pool, fee record, etc.) + */ +export type ModuleType = + | { tag: 'Bounty'; values: void } + | { tag: 'Crowdfund'; values: void } + | { tag: 'Grant'; values: void } + | { tag: 'Hackathon'; values: void }; + +/** + * Skill/activity categories used across reputation scoring and bounty tagging. + */ +export type ActivityCategory = + | { tag: 'Development'; values: void } + | { tag: 'Design'; values: void } + | { tag: 'Marketing'; values: void } + | { tag: 'Security'; values: void } + | { tag: 'Community'; values: void }; + +export interface Client { + /** + * Construct and simulate a init transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + init: ( + { + admin, + core_escrow, + reputation_registry, + }: { admin: string; core_escrow: string; reputation_registry: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a apply transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + apply: ( + { + applicant, + bounty_id, + proposal, + }: { applicant: string; bounty_id: u64; proposal: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a upgrade transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + upgrade: ( + { new_wasm_hash }: { new_wasm_hash: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_bounty transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_bounty: ( + { bounty_id }: { bounty_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a submit_work transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + submit_work: ( + { + contributor, + bounty_id, + work_cid, + }: { contributor: string; bounty_id: u64; work_cid: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a approve_fcfs transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + approve_fcfs: ( + { + creator, + bounty_id, + points, + }: { creator: string; bounty_id: u64; points: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a claim_bounty transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + claim_bounty: ( + { contributor, bounty_id }: { contributor: string; bounty_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a approve_split transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + approve_split: ( + { + creator, + bounty_id, + slot_index, + points, + }: { creator: string; bounty_id: u64; slot_index: u32; points: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a cancel_bounty transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + cancel_bounty: ( + { creator, bounty_id }: { creator: string; bounty_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a create_bounty transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + create_bounty: ( + { + creator, + title, + metadata_cid, + bounty_type, + amount, + asset, + category, + deadline, + }: { + creator: string; + title: string; + metadata_cid: string; + bounty_type: BountyType; + amount: i128; + asset: string; + category: ActivityCategory; + deadline: u64; + }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a define_splits transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + define_splits: ( + { + creator, + bounty_id, + slots, + }: { + creator: string; + bounty_id: u64; + slots: Array; + }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a update_bounty transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + update_bounty: ( + { + creator, + bounty_id, + title, + metadata_cid, + deadline, + }: { + creator: string; + bounty_id: u64; + title: Option; + metadata_cid: Option; + deadline: Option; + }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_application transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_application: ( + { bounty_id, applicant }: { bounty_id: u64; applicant: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a finalize_contest transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + finalize_contest: ( + { creator, bounty_id }: { creator: string; bounty_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_bounty_count transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_bounty_count: ( + options?: MethodOptions + ) => Promise>; + + /** + * Construct and simulate a select_applicant transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + select_applicant: ( + { + creator, + bounty_id, + applicant, + }: { creator: string; bounty_id: u64; applicant: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a approve_submission transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + approve_submission: ( + { + creator, + bounty_id, + points, + }: { creator: string; bounty_id: u64; points: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a auto_release_check transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + auto_release_check: ( + { bounty_id }: { bounty_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a reject_application transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + reject_application: ( + { + creator, + bounty_id, + applicant, + }: { creator: string; bounty_id: u64; applicant: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a approve_contest_winner transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + approve_contest_winner: ( + { + creator, + bounty_id, + winner, + payout_amount, + points, + }: { + creator: string; + bounty_id: u64; + winner: string; + payout_amount: i128; + points: u32; + }, + options?: MethodOptions + ) => Promise>>; +} +export class Client extends ContractClient { + static async deploy( + /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */ + options: MethodOptions & + Omit & { + /** The hash of the Wasm blob, which must already be installed on-chain. */ + wasmHash: Buffer | string; + /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */ + salt?: Buffer | Uint8Array; + /** The format used to decode `wasmHash`, if it's provided as a string. */ + format?: 'hex' | 'base64'; + } + ): Promise> { + return ContractClient.deploy(null, options); + } + constructor(public readonly options: ContractClientOptions) { + super( + new ContractSpec([ + 'AAAABAAAAAAAAAAAAAAAC0JvdW50eUVycm9yAAAAABsAAAAAAAAAEkFscmVhZHlJbml0aWFsaXplZAAAAAACvAAAAAAAAAA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AAAC0RldmVsb3BtZW50AAAAAAAAAAAAAAAABkRlc2lnbgAAAAAAAAAAAAAAAAAJTWFya2V0aW5nAAAAAAAAAAAAAAAAAAAIU2VjdXJpdHkAAAAAAAAAAAAAAAlDb21tdW5pdHkAAAA=', + ]), + options + ); + } + public readonly fromJSON = { + init: this.txFromJSON>, + apply: this.txFromJSON>, + upgrade: this.txFromJSON>, + get_bounty: this.txFromJSON>, + submit_work: this.txFromJSON>, + approve_fcfs: this.txFromJSON>, + claim_bounty: this.txFromJSON>, + approve_split: this.txFromJSON>, + cancel_bounty: this.txFromJSON>, + create_bounty: this.txFromJSON>, + define_splits: this.txFromJSON>, + update_bounty: this.txFromJSON>, + get_application: this.txFromJSON>, + finalize_contest: this.txFromJSON>, + get_bounty_count: this.txFromJSON, + select_applicant: this.txFromJSON>, + approve_submission: this.txFromJSON>, + auto_release_check: this.txFromJSON>, + reject_application: this.txFromJSON>, + approve_contest_winner: this.txFromJSON>, + }; +} diff --git a/lib/contracts/bounty-registry/tsconfig.json b/lib/contracts/bounty-registry/tsconfig.json new file mode 100644 index 00000000..d434bd44 --- /dev/null +++ b/lib/contracts/bounty-registry/tsconfig.json @@ -0,0 +1,96 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + /* Language and Environment */ + "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + /* Modules */ + "module": "NodeNext" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "nodenext" /* Specify how TypeScript looks up a file from a given module specifier. */, + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + /* Emit */ + "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./dist" /* Specify an output folder for all emitted files. */, + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + /* Interop Constraints */ + "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + // "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + // "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + /* Type Checking */ + // "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + "strict": true /* When type checking, take into account 'null' and 'undefined'. */, + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "include": ["src/*"] +} diff --git a/lib/contracts/core-escrow/.gitignore b/lib/contracts/core-escrow/.gitignore new file mode 100644 index 00000000..e1e671ac --- /dev/null +++ b/lib/contracts/core-escrow/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +out/ + +dist/ diff --git a/lib/contracts/core-escrow/README.md b/lib/contracts/core-escrow/README.md new file mode 100644 index 00000000..5a5df47f --- /dev/null +++ b/lib/contracts/core-escrow/README.md @@ -0,0 +1,54 @@ +# core-escrow JS + +JS library for interacting with [Soroban](https://soroban.stellar.org/) smart contract `core-escrow` via Soroban RPC. + +This library was automatically generated by Soroban CLI using a command similar to: + +```bash +soroban contract bindings ts \ + --rpc-url https://soroban-testnet.stellar.org:443 \ + --network-passphrase "Test SDF Network ; September 2015" \ + --contract-id CA3VZVIMGLVG5EJF2ACB3LPMGQ6PID4TJTB3D2B3L6JIZRIS7NQPVPHN \ + --output-dir ./path/to/core-escrow +``` + +The network passphrase and contract ID are exported from [index.ts](./src/index.ts) in the `networks` constant. If you are the one who generated this library and you know that this contract is also deployed to other networks, feel free to update `networks` with other valid options. This will help your contract consumers use this library more easily. + +# To publish or not to publish + +This library is suitable for publishing to NPM. You can publish it to NPM using the `npm publish` command. + +But you don't need to publish this library to NPM to use it. You can add it to your project's `package.json` using a file path: + +```json +"dependencies": { + "core-escrow": "./path/to/this/folder" +} +``` + +However, we've actually encountered [frustration](https://github.com/stellar/soroban-example-dapp/pull/117#discussion_r1232873560) using local libraries with NPM in this way. Though it seems a bit messy, we suggest generating the library directly to your `node_modules` folder automatically after each install by using a `postinstall` script. We've had the least trouble with this approach. NPM will automatically remove what it sees as erroneous directories during the `install` step, and then regenerate them when it gets to your `postinstall` step, which will keep the library up-to-date with your contract. + +```json +"scripts": { + "postinstall": "soroban contract bindings ts --rpc-url https://soroban-testnet.stellar.org:443 --network-passphrase \"Test SDF Network ; September 2015\" --id CA3VZVIMGLVG5EJF2ACB3LPMGQ6PID4TJTB3D2B3L6JIZRIS7NQPVPHN --name core-escrow" +} +``` + +Obviously you need to adjust the above command based on the actual command you used to generate the library. + +# Use it + +Now that you have your library up-to-date and added to your project, you can import it in a file and see inline documentation for all of its exported methods: + +```js +import { Contract, networks } from "core-escrow" + +const contract = new Contract({ + ...networks.testnet, // for example; check which networks this library exports + rpcUrl: '...', // use your own, or find one for testing at https://soroban.stellar.org/docs/reference/rpc#public-rpc-providers +}) + +contract.| +``` + +As long as your editor is configured to show JavaScript/TypeScript documentation, you can pause your typing at that `|` to get a list of all exports and inline-documentation for each. It exports a separate [async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function for each method in the smart contract, with documentation for each generated from the comments the contract's author included in the original source code. diff --git a/lib/contracts/core-escrow/package.json b/lib/contracts/core-escrow/package.json new file mode 100644 index 00000000..ac5384a0 --- /dev/null +++ b/lib/contracts/core-escrow/package.json @@ -0,0 +1,17 @@ +{ + "version": "0.0.0", + "name": "core-escrow", + "type": "module", + "exports": "./dist/index.js", + "typings": "dist/index.d.ts", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@stellar/stellar-sdk": "^14.6.1", + "buffer": "^6.0.3" + }, + "devDependencies": { + "typescript": "^5.6.2" + } +} diff --git a/lib/contracts/core-escrow/src/index.ts b/lib/contracts/core-escrow/src/index.ts new file mode 100644 index 00000000..570c328f --- /dev/null +++ b/lib/contracts/core-escrow/src/index.ts @@ -0,0 +1,623 @@ +import { Buffer } from 'buffer'; +import { Address } from '@stellar/stellar-sdk'; +import { + AssembledTransaction, + Client as ContractClient, + ClientOptions as ContractClientOptions, + MethodOptions, + Result, + Spec as ContractSpec, +} from '@stellar/stellar-sdk/contract'; +import type { + u32, + i32, + u64, + i64, + u128, + i128, + u256, + i256, + Option, +} from '@stellar/stellar-sdk/contract'; +export * from '@stellar/stellar-sdk'; +export * as contract from '@stellar/stellar-sdk/contract'; +export * as rpc from '@stellar/stellar-sdk/rpc'; + +if (typeof window !== 'undefined') { + //@ts-ignore Buffer exists + window.Buffer = window.Buffer || Buffer; +} + +export const networks = { + testnet: { + networkPassphrase: 'Test SDF Network ; September 2015', + contractId: 'CA3VZVIMGLVG5EJF2ACB3LPMGQ6PID4TJTB3D2B3L6JIZRIS7NQPVPHN', + }, +} as const; + +export const EscrowError = { + 100: { message: 'AlreadyInitialized' }, + 101: { message: 'NotInitialized' }, + 102: { message: 'NotAuthorized' }, + 103: { message: 'PoolNotFound' }, + 104: { message: 'PoolAlreadyExists' }, + 105: { message: 'PoolLocked' }, + 106: { message: 'PoolNotLocked' }, + 107: { message: 'InvalidAsset' }, + 108: { message: 'InsufficientFunds' }, + 109: { message: 'SlotNotFound' }, + 110: { message: 'SlotAlreadyReleased' }, + 111: { message: 'SlotsExceedDeposit' }, + 112: { message: 'InvalidAmount' }, + 113: { message: 'RateExceedsLimit' }, + 114: { message: 'RoutingPaused' }, + 115: { message: 'InsuranceCutOutOfRange' }, + 116: { message: 'Overflow' }, + 117: { message: 'ModuleNotAuthorized' }, + 118: { message: 'PoolExpired' }, + 119: { message: 'InsuranceInsufficient' }, +}; + +export interface FeeConfig { + bounty_fee_bps: u32; + crowdfund_fee_bps: u32; + grant_fee_bps: u32; + hackathon_fee_bps: u32; + insurance_cut_bps: u32; +} + +export interface FeeRecord { + fee_amount: i128; + gross_amount: i128; + insurance_cut: i128; + net_to_escrow: i128; + payer: string; + pool_id: Buffer; + sub_type: SubType; + timestamp: u64; + treasury_cut: i128; +} + +export interface EscrowPool { + asset: string; + authorized_caller: string; + created_at: u64; + expires_at: u64; + locked: boolean; + module: ModuleType; + owner: string; + pool_id: Buffer; + total_deposited: i128; + total_refunded: i128; + total_released: i128; +} + +export interface ReleaseSlot { + amount: i128; + pool_id: Buffer; + recipient: string; + released: boolean; + released_at: Option; + slot_index: u32; +} + +export type EscrowDataKey = + | { tag: 'Admin'; values: void } + | { tag: 'Treasury'; values: void } + | { tag: 'FeeConfig'; values: void } + | { tag: 'InsuranceFund'; values: void } + | { tag: 'RoutingPaused'; values: void } + | { tag: 'Version'; values: void } + | { tag: 'EscrowPool'; values: readonly [Buffer] } + | { tag: 'ReleaseSlot'; values: readonly [Buffer, u32] } + | { tag: 'SlotCount'; values: readonly [Buffer] } + | { tag: 'FeeRecord'; values: readonly [Buffer] } + | { tag: 'AuthorizedModule'; values: readonly [string] }; + +export interface InsuranceFund { + balance: i128; + total_contributions: i128; + total_paid_out: i128; +} + +/** + * Granular sub-type for fee rate lookup and audit trail. + */ +export type SubType = + | { tag: 'BountyFCFS'; values: void } + | { tag: 'BountyApplication'; values: void } + | { tag: 'BountyContest'; values: void } + | { tag: 'BountySplit'; values: void } + | { tag: 'CrowdfundPledge'; values: void } + | { tag: 'GrantMilestone'; values: void } + | { tag: 'GrantRetrospective'; values: void } + | { tag: 'GrantQFMatchingPool'; values: void } + | { tag: 'HackathonMain'; values: void } + | { tag: 'HackathonTrack'; values: void }; + +/** + * Identifies which platform module owns a resource (escrow pool, fee record, etc.) + */ +export type ModuleType = + | { tag: 'Bounty'; values: void } + | { tag: 'Crowdfund'; values: void } + | { tag: 'Grant'; values: void } + | { tag: 'Hackathon'; values: void }; + +/** + * Skill/activity categories used across reputation scoring and bounty tagging. + */ +export type ActivityCategory = + | { tag: 'Development'; values: void } + | { tag: 'Design'; values: void } + | { tag: 'Marketing'; values: void } + | { tag: 'Security'; values: void } + | { tag: 'Community'; values: void }; + +export interface Client { + /** + * Construct and simulate a init transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + init: ( + { admin, treasury }: { admin: string; treasury: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a deposit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + deposit: ( + { + pool_id, + amount, + payer, + }: { pool_id: Buffer; amount: i128; payer: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a upgrade transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + upgrade: ( + { new_wasm_hash }: { new_wasm_hash: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_pool transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_pool: ( + { pool_id }: { pool_id: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_slot transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_slot: ( + { pool_id, index }: { pool_id: Buffer; index: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_admin transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_admin: ( + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a is_locked transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + is_locked: ( + { pool_id }: { pool_id: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a lock_pool transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + lock_pool: ( + { pool_id }: { pool_id: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a refund_all transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + refund_all: ( + { pool_id }: { pool_id: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a create_pool transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + create_pool: ( + { + owner, + module, + module_id, + total_amount, + asset, + expires_at, + authorized_caller, + }: { + owner: string; + module: ModuleType; + module_id: u64; + total_amount: i128; + asset: string; + expires_at: u64; + authorized_caller: string; + }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_fee_rate transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_fee_rate: ( + { sub_type }: { sub_type: SubType }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_treasury transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_treasury: ( + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a release_slot transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + release_slot: ( + { pool_id, slot_index }: { pool_id: Buffer; slot_index: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a route_payout transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Convenience wrapper: release escrow to recipient with no fee. + * Calls release_partial internally. + */ + route_payout: ( + { + pool_id, + recipient, + amount, + }: { pool_id: Buffer; recipient: string; amount: i128 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a route_pledge transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + route_pledge: ( + { + backer, + pool_id, + pledge_amount, + asset, + }: { backer: string; pool_id: Buffer; pledge_amount: i128; asset: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a route_refund transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Convenience wrapper: refund escrowed net amount to pool owner. + * Calls refund_all internally. + */ + route_refund: ( + { pool_id }: { pool_id: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a set_fee_rate transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + set_fee_rate: ( + { sub_type, new_bps }: { sub_type: SubType; new_bps: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a update_admin transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + update_admin: ( + { new_admin }: { new_admin: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a calculate_fee transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + calculate_fee: ( + { gross, sub_type }: { gross: i128; sub_type: SubType }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a pause_routing transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + pause_routing: ( + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a route_deposit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + route_deposit: ( + { + payer, + pool_id, + gross_amount, + asset, + sub_type, + }: { + payer: string; + pool_id: Buffer; + gross_amount: i128; + asset: string; + sub_type: SubType; + }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_fee_config transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_fee_config: ( + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_fee_record transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_fee_record: ( + { pool_id }: { pool_id: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_unreleased transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_unreleased: ( + { pool_id }: { pool_id: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a refund_backers transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + refund_backers: ( + { + pool_id, + backers, + }: { pool_id: Buffer; backers: Array }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a resume_routing transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + resume_routing: ( + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a claim_insurance transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + claim_insurance: ( + { + claimant, + amount, + asset, + }: { claimant: string; amount: i128; asset: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a release_partial transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + release_partial: ( + { + pool_id, + recipient, + amount, + }: { pool_id: Buffer; recipient: string; amount: i128 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a update_treasury transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + update_treasury: ( + { new_treasury }: { new_treasury: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a authorize_module transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + authorize_module: ( + { module_addr }: { module_addr: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a refund_remaining transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + refund_remaining: ( + { pool_id }: { pool_id: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a set_insurance_cut transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + set_insurance_cut: ( + { new_bps }: { new_bps: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a deauthorize_module transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + deauthorize_module: ( + { module_addr }: { module_addr: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a contribute_insurance transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + contribute_insurance: ( + { amount }: { amount: i128 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a define_release_slots transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + define_release_slots: ( + { + pool_id, + slots, + }: { pool_id: Buffer; slots: Array }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a calculate_pledge_cost transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + calculate_pledge_cost: ( + { pledge }: { pledge: i128 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_insurance_balance transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_insurance_balance: ( + options?: MethodOptions + ) => Promise>; +} +export class Client extends ContractClient { + static async deploy( + /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */ + options: MethodOptions & + Omit & { + /** The hash of the Wasm blob, which must already be installed on-chain. */ + wasmHash: Buffer | string; + /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */ + salt?: Buffer | Uint8Array; + /** The format used to decode `wasmHash`, if it's provided as a string. */ + format?: 'hex' | 'base64'; + } + ): Promise> { + return ContractClient.deploy(null, options); + } + constructor(public readonly options: ContractClientOptions) { + super( + new ContractSpec([ + 'AAAABAAAAAAAAAAAAAAAC0VzY3Jvd0Vycm9yAAAAABQAAAAAAAAAEkFscmVhZHlJbml0aWFsaXplZAAAAAAAZAAAAAAAAAAOTm90SW5pdGlhbGl6ZWQAAAAAAGUAAAAAAAAADU5vdEF1dGhvcml6ZWQAAAAAAABmAAAAAAAAAAxQb29sTm90Rm91bmQAAABnAAAAAAAAABFQb29sQWxyZWFkeUV4aXN0cwAAAAAAAGgAAAAAAAAAClBvb2xMb2NrZWQAAAAAAGkAAAAAAAAADVBvb2xOb3RMb2NrZWQAAAAAAABqAAAAAAAAAAxJbnZhbGlkQXNzZXQAAABrAAAAAAAAABFJbnN1ZmZpY2llbnRGdW5kcwAAAAAAAGwAAAAAAAAADFNsb3ROb3RGb3VuZAAAAG0AAAAAAAAAE1Nsb3RBbHJlYWR5UmVsZWFzZWQAAAAAbgAAAAAAAAASU2xvdHNFeGNlZWREZXBvc2l0AAAAAABvAAAAAAAAAA1JbnZhbGlkQW1vdW50AAAAAAAAcAAAAAAAAAAQUmF0ZUV4Y2VlZHNMaW1pdAAAAHEAAAAAAAAADVJvdXRpbmdQYXVzZWQAAAAAAAByAAAAAAAAABZJbnN1cmFuY2VDdXRPdXRPZlJhbmdlAAAAAABzAAAAAAAAAAhPdmVyZmxvdwAAAHQAAAAAAAAAE01vZHVsZU5vdEF1dGhvcml6ZWQAAAAAdQAAAAAAAAALUG9vbEV4cGlyZWQAAAAAdgAAAAAAAAAVSW5zdXJhbmNlSW5zdWZmaWNpZW50AAAAAAAAdw==', + 'AAAABQAAAAAAAAAAAAAACFJlZnVuZGVkAAAAAQAAAAhyZWZ1bmRlZAAAAAMAAAAAAAAAB3Bvb2xfaWQAAAAD7gAAACAAAAABAAA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AAABAAAAAAAAAAAAAAABkJvdW50eQAAAAAAAAAAAAAAAAAJQ3Jvd2RmdW5kAAAAAAAAAAAAAAAAAAAFR3JhbnQAAAAAAAAAAAAAAAAAAAlIYWNrYXRob24AAAA=', + 'AAAAAgAAAExTa2lsbC9hY3Rpdml0eSBjYXRlZ29yaWVzIHVzZWQgYWNyb3NzIHJlcHV0YXRpb24gc2NvcmluZyBhbmQgYm91bnR5IHRhZ2dpbmcuAAAAAAAAABBBY3Rpdml0eUNhdGVnb3J5AAAABQAAAAAAAAAAAAAAC0RldmVsb3BtZW50AAAAAAAAAAAAAAAABkRlc2lnbgAAAAAAAAAAAAAAAAAJTWFya2V0aW5nAAAAAAAAAAAAAAAAAAAIU2VjdXJpdHkAAAAAAAAAAAAAAAlDb21tdW5pdHkAAAA=', + ]), + options + ); + } + public readonly fromJSON = { + init: this.txFromJSON>, + deposit: this.txFromJSON>, + upgrade: this.txFromJSON>, + get_pool: this.txFromJSON>, + get_slot: this.txFromJSON>, + get_admin: this.txFromJSON>, + is_locked: this.txFromJSON>, + lock_pool: this.txFromJSON>, + refund_all: this.txFromJSON>, + create_pool: this.txFromJSON>, + get_fee_rate: this.txFromJSON>, + get_treasury: this.txFromJSON>, + release_slot: this.txFromJSON>, + route_payout: this.txFromJSON>, + route_pledge: this.txFromJSON>, + route_refund: this.txFromJSON>, + set_fee_rate: this.txFromJSON>, + update_admin: this.txFromJSON>, + calculate_fee: this.txFromJSON>, + pause_routing: this.txFromJSON>, + route_deposit: this.txFromJSON>, + get_fee_config: this.txFromJSON>, + get_fee_record: this.txFromJSON>, + get_unreleased: this.txFromJSON>, + refund_backers: this.txFromJSON>, + resume_routing: this.txFromJSON>, + claim_insurance: this.txFromJSON>, + release_partial: this.txFromJSON>, + update_treasury: this.txFromJSON>, + authorize_module: this.txFromJSON>, + refund_remaining: this.txFromJSON>, + set_insurance_cut: this.txFromJSON>, + deauthorize_module: this.txFromJSON>, + contribute_insurance: this.txFromJSON>, + define_release_slots: this.txFromJSON>, + calculate_pledge_cost: this.txFromJSON>, + get_insurance_balance: this.txFromJSON, + }; +} diff --git a/lib/contracts/core-escrow/tsconfig.json b/lib/contracts/core-escrow/tsconfig.json new file mode 100644 index 00000000..d434bd44 --- /dev/null +++ b/lib/contracts/core-escrow/tsconfig.json @@ -0,0 +1,96 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + /* Language and Environment */ + "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + /* Modules */ + "module": "NodeNext" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "nodenext" /* Specify how TypeScript looks up a file from a given module specifier. */, + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + /* Emit */ + "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./dist" /* Specify an output folder for all emitted files. */, + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + /* Interop Constraints */ + "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + // "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + // "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + /* Type Checking */ + // "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + "strict": true /* When type checking, take into account 'null' and 'undefined'. */, + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "include": ["src/*"] +} diff --git a/lib/contracts/index.ts b/lib/contracts/index.ts new file mode 100644 index 00000000..cb225a56 --- /dev/null +++ b/lib/contracts/index.ts @@ -0,0 +1,144 @@ +import type { ClientOptions as ContractClientOptions } from '@stellar/stellar-sdk/contract'; +import { Client as BountyRegistryClient } from './bounty-registry/src/index'; +import { Client as CoreEscrowClient } from './core-escrow/src/index'; +import { Client as ReputationRegistryClient } from './reputation-registry/src/index'; +import { Client as ProjectRegistryClient } from './project-registry/src/index'; + +export type { + BountyRegistryClient, + CoreEscrowClient, + ReputationRegistryClient, + ProjectRegistryClient, +}; +export * from './bounty-registry/src/index'; +export * as coreEscrowBindings from './core-escrow/src/index'; +export * as reputationRegistryBindings from './reputation-registry/src/index'; +export * as projectRegistryBindings from './project-registry/src/index'; +export * from './transaction'; + +// ─── Network config ──────────────────────────────────────────────────────────── + +const STELLAR_NETWORK = + process.env.NEXT_PUBLIC_STELLAR_NETWORK === 'public' ? 'public' : 'testnet'; + +const RPC_URLS: Record = { + testnet: 'https://soroban-testnet.stellar.org', + public: 'https://mainnet.sorobanrpc.com', +}; + +const NETWORK_PASSPHRASES: Record = { + testnet: 'Test SDF Network ; September 2015', + public: 'Public Global Stellar Network ; September 2015', +}; + +// ─── Contract addresses ──────────────────────────────────────────────────────── +// Testnet defaults are provided for convenience. For mainnet, set the +// corresponding NEXT_PUBLIC_*_CONTRACT_ID environment variables explicitly. + +const TESTNET_ADDRESSES = { + bountyRegistry: 'CBWXIV3DERH4GKADOTEEI2QADGZAMMJT4T2B5LFVZULGHEP5BACK2TLY', + coreEscrow: 'CA3VZVIMGLVG5EJF2ACB3LPMGQ6PID4TJTB3D2B3L6JIZRIS7NQPVPHN', + reputationRegistry: + 'CBVQEDH4T5KOJQSESL2HEFI2YZWXPSZQ5TASKRNWAVZFIWAKEU74RFF4', + projectRegistry: 'CCG4QM2GZKBN7GBRAE3PFNE3GM2B6QRS7FOKLHGV2FT2HHETIS7JUVYT', +} as const; + +function resolveAddress( + envVar: string | undefined, + contractKey: keyof typeof TESTNET_ADDRESSES +): string { + if (envVar) return envVar; + if (STELLAR_NETWORK === 'testnet') return TESTNET_ADDRESSES[contractKey]; + throw new Error( + `Contract address for "${contractKey}" must be set via environment variable on mainnet.` + ); +} + +const CONTRACT_ADDRESSES = { + bountyRegistry: resolveAddress( + process.env.NEXT_PUBLIC_BOUNTY_REGISTRY_CONTRACT_ID, + 'bountyRegistry' + ), + coreEscrow: resolveAddress( + process.env.NEXT_PUBLIC_CORE_ESCROW_CONTRACT_ID, + 'coreEscrow' + ), + reputationRegistry: resolveAddress( + process.env.NEXT_PUBLIC_REPUTATION_REGISTRY_CONTRACT_ID, + 'reputationRegistry' + ), + projectRegistry: resolveAddress( + process.env.NEXT_PUBLIC_PROJECT_REGISTRY_CONTRACT_ID, + 'projectRegistry' + ), +}; + +// ─── Helpers ─────────────────────────────────────────────────────────────────── + +export function getRpcUrl(): string { + return RPC_URLS[STELLAR_NETWORK]; +} + +export function getNetworkPassphrase(): string { + return NETWORK_PASSPHRASES[STELLAR_NETWORK]; +} + +function baseClientOptions(contractId: string): ContractClientOptions { + return { + contractId, + networkPassphrase: getNetworkPassphrase(), + rpcUrl: getRpcUrl(), + }; +} + +// ─── Client factories ────────────────────────────────────────────────────────── + +/** + * Create a Bounty Registry client. + * Pass `publicKey` to enable transaction building for write operations. + */ +export function createBountyRegistryClient( + publicKey?: string +): BountyRegistryClient { + return new BountyRegistryClient({ + ...baseClientOptions(CONTRACT_ADDRESSES.bountyRegistry), + ...(publicKey ? { publicKey } : {}), + }); +} + +/** + * Create a Core Escrow client. + * Pass `publicKey` to enable transaction building for write operations. + */ +export function createCoreEscrowClient(publicKey?: string): CoreEscrowClient { + return new CoreEscrowClient({ + ...baseClientOptions(CONTRACT_ADDRESSES.coreEscrow), + ...(publicKey ? { publicKey } : {}), + }); +} + +/** + * Create a Reputation Registry client. + * Pass `publicKey` to enable transaction building for write operations. + */ +export function createReputationRegistryClient( + publicKey?: string +): ReputationRegistryClient { + return new ReputationRegistryClient({ + ...baseClientOptions(CONTRACT_ADDRESSES.reputationRegistry), + ...(publicKey ? { publicKey } : {}), + }); +} + +/** + * Create a Project Registry client. + * Pass `publicKey` to enable transaction building for write operations. + */ +export function createProjectRegistryClient( + publicKey?: string +): ProjectRegistryClient { + return new ProjectRegistryClient({ + ...baseClientOptions(CONTRACT_ADDRESSES.projectRegistry), + ...(publicKey ? { publicKey } : {}), + }); +} diff --git a/lib/contracts/project-registry/.gitignore b/lib/contracts/project-registry/.gitignore new file mode 100644 index 00000000..e1e671ac --- /dev/null +++ b/lib/contracts/project-registry/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +out/ + +dist/ diff --git a/lib/contracts/project-registry/README.md b/lib/contracts/project-registry/README.md new file mode 100644 index 00000000..05260667 --- /dev/null +++ b/lib/contracts/project-registry/README.md @@ -0,0 +1,54 @@ +# project-registry JS + +JS library for interacting with [Soroban](https://soroban.stellar.org/) smart contract `project-registry` via Soroban RPC. + +This library was automatically generated by Soroban CLI using a command similar to: + +```bash +soroban contract bindings ts \ + --rpc-url https://soroban-testnet.stellar.org:443 \ + --network-passphrase "Test SDF Network ; September 2015" \ + --contract-id CCG4QM2GZKBN7GBRAE3PFNE3GM2B6QRS7FOKLHGV2FT2HHETIS7JUVYT \ + --output-dir ./path/to/project-registry +``` + +The network passphrase and contract ID are exported from [index.ts](./src/index.ts) in the `networks` constant. If you are the one who generated this library and you know that this contract is also deployed to other networks, feel free to update `networks` with other valid options. This will help your contract consumers use this library more easily. + +# To publish or not to publish + +This library is suitable for publishing to NPM. You can publish it to NPM using the `npm publish` command. + +But you don't need to publish this library to NPM to use it. You can add it to your project's `package.json` using a file path: + +```json +"dependencies": { + "project-registry": "./path/to/this/folder" +} +``` + +However, we've actually encountered [frustration](https://github.com/stellar/soroban-example-dapp/pull/117#discussion_r1232873560) using local libraries with NPM in this way. Though it seems a bit messy, we suggest generating the library directly to your `node_modules` folder automatically after each install by using a `postinstall` script. We've had the least trouble with this approach. NPM will automatically remove what it sees as erroneous directories during the `install` step, and then regenerate them when it gets to your `postinstall` step, which will keep the library up-to-date with your contract. + +```json +"scripts": { + "postinstall": "soroban contract bindings ts --rpc-url https://soroban-testnet.stellar.org:443 --network-passphrase \"Test SDF Network ; September 2015\" --id CCG4QM2GZKBN7GBRAE3PFNE3GM2B6QRS7FOKLHGV2FT2HHETIS7JUVYT --name project-registry" +} +``` + +Obviously you need to adjust the above command based on the actual command you used to generate the library. + +# Use it + +Now that you have your library up-to-date and added to your project, you can import it in a file and see inline documentation for all of its exported methods: + +```js +import { Client, networks } from "project-registry" + +const contract = new Client({ + ...networks.testnet, // for example; check which networks this library exports + rpcUrl: '...', // use your own, or find one for testing at https://soroban.stellar.org/docs/reference/rpc#public-rpc-providers +}) + +contract.| +``` + +As long as your editor is configured to show JavaScript/TypeScript documentation, you can pause your typing at that `|` to get a list of all exports and inline-documentation for each. It exports a separate [async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function for each method in the smart contract, with documentation for each generated from the comments the contract's author included in the original source code. diff --git a/lib/contracts/project-registry/package.json b/lib/contracts/project-registry/package.json new file mode 100644 index 00000000..dbb99749 --- /dev/null +++ b/lib/contracts/project-registry/package.json @@ -0,0 +1,17 @@ +{ + "version": "0.0.0", + "name": "project-registry", + "type": "module", + "exports": "./dist/index.js", + "typings": "dist/index.d.ts", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@stellar/stellar-sdk": "^14.6.1", + "buffer": "^6.0.3" + }, + "devDependencies": { + "typescript": "^5.6.2" + } +} diff --git a/lib/contracts/project-registry/src/index.ts b/lib/contracts/project-registry/src/index.ts new file mode 100644 index 00000000..a1e69c6f --- /dev/null +++ b/lib/contracts/project-registry/src/index.ts @@ -0,0 +1,375 @@ +import { Buffer } from 'buffer'; +import { Address } from '@stellar/stellar-sdk'; +import { + AssembledTransaction, + Client as ContractClient, + ClientOptions as ContractClientOptions, + MethodOptions, + Result, + Spec as ContractSpec, +} from '@stellar/stellar-sdk/contract'; +import type { + u32, + i32, + u64, + i64, + u128, + i128, + u256, + i256, + Option, +} from '@stellar/stellar-sdk/contract'; +export * from '@stellar/stellar-sdk'; +export * as contract from '@stellar/stellar-sdk/contract'; +export * as rpc from '@stellar/stellar-sdk/rpc'; + +if (typeof window !== 'undefined') { + //@ts-ignore Buffer exists + window.Buffer = window.Buffer || Buffer; +} + +export const networks = { + testnet: { + networkPassphrase: 'Test SDF Network ; September 2015', + contractId: 'CCG4QM2GZKBN7GBRAE3PFNE3GM2B6QRS7FOKLHGV2FT2HHETIS7JUVYT', + }, +} as const; + +export const ProjectError = { + 600: { message: 'AlreadyInitialized' }, + 601: { message: 'NotInitialized' }, + 602: { message: 'NotAuthorized' }, + 603: { message: 'ProjectNotFound' }, + 604: { message: 'ProjectSuspended' }, + 605: { message: 'BudgetExceedsLimit' }, + 606: { message: 'ModuleNotAuthorized' }, + 607: { message: 'InsufficientDeposit' }, + 608: { message: 'NoDepositHeld' }, + 609: { message: 'InvalidAmount' }, + 610: { message: 'Overflow' }, +}; + +export interface Project { + active_bounty_budget: i128; + avg_rating: u32; + bounties_posted: u32; + campaigns_launched: u32; + deposit_held: i128; + dispute_count: u32; + grants_distributed: i128; + hackathons_hosted: u32; + id: u64; + metadata_cid: string; + missed_milestones: u32; + owner: string; + suspended: boolean; + total_paid_out: i128; + total_platform_spend: i128; + verification_level: u32; + warning_level: u32; +} + +export type ProjectDataKey = + | { tag: 'Admin'; values: void } + | { tag: 'Version'; values: void } + | { tag: 'ProjectCount'; values: void } + | { tag: 'Project'; values: readonly [u64] } + | { tag: 'AuthorizedModule'; values: readonly [string] }; + +/** + * Granular sub-type for fee rate lookup and audit trail. + */ +export type SubType = + | { tag: 'BountyFCFS'; values: void } + | { tag: 'BountyApplication'; values: void } + | { tag: 'BountyContest'; values: void } + | { tag: 'BountySplit'; values: void } + | { tag: 'CrowdfundPledge'; values: void } + | { tag: 'GrantMilestone'; values: void } + | { tag: 'GrantRetrospective'; values: void } + | { tag: 'GrantQFMatchingPool'; values: void } + | { tag: 'HackathonMain'; values: void } + | { tag: 'HackathonTrack'; values: void }; + +/** + * Identifies which platform module owns a resource (escrow pool, fee record, etc.) + */ +export type ModuleType = + | { tag: 'Bounty'; values: void } + | { tag: 'Crowdfund'; values: void } + | { tag: 'Grant'; values: void } + | { tag: 'Hackathon'; values: void }; + +/** + * Skill/activity categories used across reputation scoring and bounty tagging. + */ +export type ActivityCategory = + | { tag: 'Development'; values: void } + | { tag: 'Design'; values: void } + | { tag: 'Marketing'; values: void } + | { tag: 'Security'; values: void } + | { tag: 'Community'; values: void }; + +export interface Client { + /** + * Construct and simulate a init transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + init: ( + { admin }: { admin: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a upgrade transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + upgrade: ( + { new_wasm_hash }: { new_wasm_hash: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_project transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_project: ( + { project_id }: { project_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a is_suspended transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + is_suspended: ( + { project_id }: { project_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a lock_deposit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Lock a deposit for a project. Called by the project owner before posting a bounty/campaign. + */ + lock_deposit: ( + { + project_id, + amount, + asset, + }: { project_id: u64; amount: i128; asset: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_payout transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + record_payout: ( + { + module, + project_id, + amount, + }: { module: string; project_id: u64; amount: i128 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_dispute transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + record_dispute: ( + { module, project_id }: { module: string; project_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a forfeit_deposit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Forfeit deposit to treasury. Called by admin on violations. + */ + forfeit_deposit: ( + { + project_id, + amount, + asset, + treasury, + }: { project_id: u64; amount: i128; asset: string; treasury: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a release_deposit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Release deposit back to project owner. Called by authorized module on successful completion. + */ + release_deposit: ( + { + module, + project_id, + amount, + asset, + }: { module: string; project_id: u64; amount: i128; asset: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a suspend_project transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + suspend_project: ( + { project_id }: { project_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a validate_budget transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + validate_budget: ( + { project_id, budget }: { project_id: u64; budget: i128 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_deposit_rate transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Get the deposit rate in basis points for a verification level. + */ + get_deposit_rate: ( + { verification_level }: { verification_level: u32 }, + options?: MethodOptions + ) => Promise>; + + /** + * Construct and simulate a register_project transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + register_project: ( + { owner, metadata_cid }: { owner: string; metadata_cid: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a calculate_deposit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Calculate the deposit required for a given budget based on project verification level. + */ + calculate_deposit: ( + { project_id, budget }: { project_id: u64; budget: i128 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a unsuspend_project transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + unsuspend_project: ( + { project_id }: { project_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_bounty_posted transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + record_bounty_posted: ( + { + module, + project_id, + budget, + }: { module: string; project_id: u64; budget: i128 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a upgrade_verification transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + upgrade_verification: ( + { project_id, new_level }: { project_id: u64; new_level: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a add_authorized_module transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + add_authorized_module: ( + { module }: { module: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_missed_milestone transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + record_missed_milestone: ( + { module, project_id }: { module: string; project_id: u64 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a remove_authorized_module transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + remove_authorized_module: ( + { module }: { module: string }, + options?: MethodOptions + ) => Promise>>; +} +export class Client extends ContractClient { + static async deploy( + /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */ + options: MethodOptions & + Omit & { + /** The hash of the Wasm blob, which must already be installed on-chain. */ + wasmHash: Buffer | string; + /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */ + salt?: Buffer | Uint8Array; + /** The format used to decode `wasmHash`, if it's provided as a string. */ + format?: 'hex' | 'base64'; + } + ): Promise> { + return ContractClient.deploy(null, options); + } + constructor(public readonly options: ContractClientOpt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GVnb3J5AAAABQAAAAAAAAAAAAAAC0RldmVsb3BtZW50AAAAAAAAAAAAAAAABkRlc2lnbgAAAAAAAAAAAAAAAAAJTWFya2V0aW5nAAAAAAAAAAAAAAAAAAAIU2VjdXJpdHkAAAAAAAAAAAAAAAlDb21tdW5pdHkAAAA=', + ]), + options + ); + } + public readonly fromJSON = { + init: this.txFromJSON>, + upgrade: this.txFromJSON>, + get_project: this.txFromJSON>, + is_suspended: this.txFromJSON>, + lock_deposit: this.txFromJSON>, + record_payout: this.txFromJSON>, + record_dispute: this.txFromJSON>, + forfeit_deposit: this.txFromJSON>, + release_deposit: this.txFromJSON>, + suspend_project: this.txFromJSON>, + validate_budget: this.txFromJSON>, + get_deposit_rate: this.txFromJSON, + register_project: this.txFromJSON>, + calculate_deposit: this.txFromJSON>, + unsuspend_project: this.txFromJSON>, + record_bounty_posted: this.txFromJSON>, + upgrade_verification: this.txFromJSON>, + add_authorized_module: this.txFromJSON>, + record_missed_milestone: this.txFromJSON>, + remove_authorized_module: this.txFromJSON>, + }; +} diff --git a/lib/contracts/project-registry/tsconfig.json b/lib/contracts/project-registry/tsconfig.json new file mode 100644 index 00000000..d434bd44 --- /dev/null +++ b/lib/contracts/project-registry/tsconfig.json @@ -0,0 +1,96 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + /* Language and Environment */ + "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + /* Modules */ + "module": "NodeNext" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "nodenext" /* Specify how TypeScript looks up a file from a given module specifier. */, + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + /* Emit */ + "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./dist" /* Specify an output folder for all emitted files. */, + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + /* Interop Constraints */ + "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + // "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + // "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + /* Type Checking */ + // "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + "strict": true /* When type checking, take into account 'null' and 'undefined'. */, + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "include": ["src/*"] +} diff --git a/lib/contracts/reputation-registry/.gitignore b/lib/contracts/reputation-registry/.gitignore new file mode 100644 index 00000000..e1e671ac --- /dev/null +++ b/lib/contracts/reputation-registry/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +out/ + +dist/ diff --git a/lib/contracts/reputation-registry/README.md b/lib/contracts/reputation-registry/README.md new file mode 100644 index 00000000..7b3cd02e --- /dev/null +++ b/lib/contracts/reputation-registry/README.md @@ -0,0 +1,54 @@ +# reputation-registry JS + +JS library for interacting with [Soroban](https://soroban.stellar.org/) smart contract `reputation-registry` via Soroban RPC. + +This library was automatically generated by Soroban CLI using a command similar to: + +```bash +soroban contract bindings ts \ + --rpc-url https://soroban-testnet.stellar.org:443 \ + --network-passphrase "Test SDF Network ; September 2015" \ + --contract-id CBVQEDH4T5KOJQSESL2HEFI2YZWXPSZQ5TASKRNWAVZFIWAKEU74RFF4 \ + --output-dir ./path/to/reputation-registry +``` + +The network passphrase and contract ID are exported from [index.ts](./src/index.ts) in the `networks` constant. If you are the one who generated this library and you know that this contract is also deployed to other networks, feel free to update `networks` with other valid options. This will help your contract consumers use this library more easily. + +# To publish or not to publish + +This library is suitable for publishing to NPM. You can publish it to NPM using the `npm publish` command. + +But you don't need to publish this library to NPM to use it. You can add it to your project's `package.json` using a file path: + +```json +"dependencies": { + "reputation-registry": "./path/to/this/folder" +} +``` + +However, we've actually encountered [frustration](https://github.com/stellar/soroban-example-dapp/pull/117#discussion_r1232873560) using local libraries with NPM in this way. Though it seems a bit messy, we suggest generating the library directly to your `node_modules` folder automatically after each install by using a `postinstall` script. We've had the least trouble with this approach. NPM will automatically remove what it sees as erroneous directories during the `install` step, and then regenerate them when it gets to your `postinstall` step, which will keep the library up-to-date with your contract. + +```json +"scripts": { + "postinstall": "soroban contract bindings ts --rpc-url https://soroban-testnet.stellar.org:443 --network-passphrase \"Test SDF Network ; September 2015\" --id CBVQEDH4T5KOJQSESL2HEFI2YZWXPSZQ5TASKRNWAVZFIWAKEU74RFF4 --name reputation-registry" +} +``` + +Obviously you need to adjust the above command based on the actual command you used to generate the library. + +# Use it + +Now that you have your library up-to-date and added to your project, you can import it in a file and see inline documentation for all of its exported methods: + +```js +import { Contract, networks } from "reputation-registry" + +const contract = new Contract({ + ...networks.testnet, // for example; check which networks this library exports + rpcUrl: '...', // use your own, or find one for testing at https://soroban.stellar.org/docs/reference/rpc#public-rpc-providers +}) + +contract.| +``` + +As long as your editor is configured to show JavaScript/TypeScript documentation, you can pause your typing at that `|` to get a list of all exports and inline-documentation for each. It exports a separate [async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function for each method in the smart contract, with documentation for each generated from the comments the contract's author included in the original source code. diff --git a/lib/contracts/reputation-registry/package.json b/lib/contracts/reputation-registry/package.json new file mode 100644 index 00000000..9b77bd07 --- /dev/null +++ b/lib/contracts/reputation-registry/package.json @@ -0,0 +1,17 @@ +{ + "version": "0.0.0", + "name": "reputation-registry", + "type": "module", + "exports": "./dist/index.js", + "typings": "dist/index.d.ts", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@stellar/stellar-sdk": "^14.6.1", + "buffer": "^6.0.3" + }, + "devDependencies": { + "typescript": "^5.6.2" + } +} diff --git a/lib/contracts/reputation-registry/src/index.ts b/lib/contracts/reputation-registry/src/index.ts new file mode 100644 index 00000000..51ce7d01 --- /dev/null +++ b/lib/contracts/reputation-registry/src/index.ts @@ -0,0 +1,455 @@ +import { Buffer } from 'buffer'; +import { Address } from '@stellar/stellar-sdk'; +import { + AssembledTransaction, + Client as ContractClient, + ClientOptions as ContractClientOptions, + MethodOptions, + Result, + Spec as ContractSpec, +} from '@stellar/stellar-sdk/contract'; +import type { + u32, + i32, + u64, + i64, + u128, + i128, + u256, + i256, + Option, +} from '@stellar/stellar-sdk/contract'; +export * from '@stellar/stellar-sdk'; +export * as contract from '@stellar/stellar-sdk/contract'; +export * as rpc from '@stellar/stellar-sdk/rpc'; + +if (typeof window !== 'undefined') { + //@ts-ignore Buffer exists + window.Buffer = window.Buffer || Buffer; +} + +export const networks = { + testnet: { + networkPassphrase: 'Test SDF Network ; September 2015', + contractId: 'CBVQEDH4T5KOJQSESL2HEFI2YZWXPSZQ5TASKRNWAVZFIWAKEU74RFF4', + }, +} as const; + +export const ReputationError = { + 300: { message: 'AlreadyInitialized' }, + 301: { message: 'NotInitialized' }, + 302: { message: 'ProfileNotFound' }, + 303: { message: 'ModuleNotAuthorized' }, + 304: { message: 'InsufficientCredits' }, + 305: { message: 'RechargeNotReady' }, +}; + +/** + * SparkCredits data (merged from SparkCredits contract) + */ +export interface CreditData { + credits: u32; + last_recharge: u64; + max_credits: u32; + total_earned: u32; + total_spent: u32; +} + +export type ReputationDataKey = + | { tag: 'Admin'; values: void } + | { tag: 'Version'; values: void } + | { tag: 'Profile'; values: readonly [string] } + | { tag: 'CreditData'; values: readonly [string] } + | { tag: 'AuthorizedModule'; values: readonly [string] }; + +export interface ContributorProfile { + address: string; + bounties_completed: u32; + campaigns_backed: u32; + category_scores: Map; + grants_received: u32; + hackathons_entered: u32; + hackathons_won: u32; + joined_at: u64; + level: u32; + metadata_cid: string; + overall_score: u32; + total_earned: i128; +} + +/** + * Granular sub-type for fee rate lookup and audit trail. + */ +export type SubType = + | { tag: 'BountyFCFS'; values: void } + | { tag: 'BountyApplication'; values: void } + | { tag: 'BountyContest'; values: void } + | { tag: 'BountySplit'; values: void } + | { tag: 'CrowdfundPledge'; values: void } + | { tag: 'GrantMilestone'; values: void } + | { tag: 'GrantRetrospective'; values: void } + | { tag: 'GrantQFMatchingPool'; values: void } + | { tag: 'HackathonMain'; values: void } + | { tag: 'HackathonTrack'; values: void }; + +/** + * Identifies which platform module owns a resource (escrow pool, fee record, etc.) + */ +export type ModuleType = + | { tag: 'Bounty'; values: void } + | { tag: 'Crowdfund'; values: void } + | { tag: 'Grant'; values: void } + | { tag: 'Hackathon'; values: void }; + +/** + * Skill/activity categories used across reputation scoring and bounty tagging. + */ +export type ActivityCategory = + | { tag: 'Development'; values: void } + | { tag: 'Design'; values: void } + | { tag: 'Marketing'; values: void } + | { tag: 'Security'; values: void } + | { tag: 'Community'; values: void }; + +export interface Client { + /** + * Construct and simulate a init transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + init: ( + { admin }: { admin: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a upgrade transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + upgrade: ( + { new_wasm_hash }: { new_wasm_hash: Buffer }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a can_apply transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + can_apply: ( + { user }: { user: string }, + options?: MethodOptions + ) => Promise>; + + /** + * Construct and simulate a get_level transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_level: ( + { contributor }: { contributor: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_credits transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_credits: ( + { user }: { user: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a get_profile transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + get_profile: ( + { contributor }: { contributor: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a init_profile transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + init_profile: ( + { contributor }: { contributor: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_fraud transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Record fraud. Admin-only. Deducts 100 reputation points. + */ + record_fraud: ( + { contributor }: { contributor: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a spend_credit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + spend_credit: ( + { module, user }: { module: string; user: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a try_recharge transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Permissionless: anyone can trigger recharge for a user after 14 days. + */ + try_recharge: ( + { user }: { user: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a award_credits transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + award_credits: ( + { module, user, amount }: { module: string; user: string; amount: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_penalty transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + record_penalty: ( + { contributor, points }: { contributor: string; points: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a restore_credit transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + restore_credit: ( + { module, user }: { module: string; user: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a next_recharge_at transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Returns the timestamp when the user can next recharge credits. + */ + next_recharge_at: ( + { user }: { user: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_completion transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + record_completion: ( + { + module, + contributor, + category, + points, + }: { + module: string; + contributor: string; + category: ActivityCategory; + points: u32; + }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a meets_requirements transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + meets_requirements: ( + { contributor, min_level }: { contributor: string; min_level: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_abandonment transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Record a contributor abandoning a bounty/task. Called by authorized modules. + * Deducts 10 reputation points. + */ + record_abandonment: ( + { module, contributor }: { module: string; contributor: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a add_community_bonus transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Add community bonus points. Admin-only. + */ + add_community_bonus: ( + { + contributor, + reason, + points, + }: { contributor: string; reason: string; points: u32 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_late_delivery transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Record a late delivery. Called by authorized modules. + * Deducts 5 reputation points. + */ + record_late_delivery: ( + { module, contributor }: { module: string; contributor: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a set_profile_metadata transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + set_profile_metadata: ( + { contributor, cid }: { contributor: string; cid: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a add_authorized_module transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + add_authorized_module: ( + { module }: { module: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_grant_received transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + record_grant_received: ( + { + module, + recipient, + amount, + }: { module: string; recipient: string; amount: i128 }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_campaign_backed transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + record_campaign_backed: ( + { module, backer }: { module: string; backer: string }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a record_hackathon_result transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + record_hackathon_result: ( + { + module, + contributor, + points, + is_win, + }: { module: string; contributor: string; points: u32; is_win: boolean }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a meets_skill_requirements transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + * Check requirements including optional category skill rating. + */ + meets_skill_requirements: ( + { + contributor, + min_level, + required_category, + min_category_score, + }: { + contributor: string; + min_level: u32; + required_category: ActivityCategory; + min_category_score: u32; + }, + options?: MethodOptions + ) => Promise>>; + + /** + * Construct and simulate a remove_authorized_module transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. + */ + remove_authorized_module: ( + { module }: { module: string }, + options?: MethodOptions + ) => Promise>>; +} +export class Client extends ContractClient { + static async deploy( + /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */ + options: MethodOptions & + Omit & { + /** The hash of the Wasm blob, which must already be installed on-chain. */ + wasmHash: Buffer | string; + /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */ + salt?: Buffer | Uint8Array; + /** The format used to decode `wasmHash`, if it's provided as a string. */ + format?: 'hex' | 'base64'; + } + ): Promise> { + return ContractClient.deploy(null, options); + } + constructor(public readonly options: ContractClientOptions) { + super( + new ContractSpec([ + 'AAAABAAAAAAAAAAAAAAAD1JlcHV0YXRpb25FcnJvcgAAAAAGAAAAAAAAABJBbHJlYWR5SW5pdGlhbGl6ZWQAAAAAASwAAAAAAAAADk5vdEluaXRpYWxpemVkAAAAAAEtAAAAAAAAAA9Qcm9maWxlTm90Rm91bmQAAAABLgAAAAAAAAATTW9kdWxlTm90QXV0aG9yaXplZAAAAAEvAAAAAAAAABNJbnN1ZmZpY2llbnRDcmVkaXRzAAAAATAAAAAAAAAAEFJlY2hhcmdlTm90UmVhZHkAAAEx', + 'AAAABQAAAAAAAAAAAAAADENyZWRpdHNTcGVudAAAAAEAAAANY3JlZGl0c19zcGVudAAAAAAAAAIAAAAAAAAABHVzZXIAAAATAAAAAQAAAAAAAAAJcmVtYWluaW5nAAAAAAAABAAAAAAAAAAC', + 'AAAABQAAAAAAAAAAAAAADFNjb3JlVXBkYXRlZAAAAAEAAAANc2NvcmVfdXBkYXRlZAAAAAAAAAMAAAAAAAAAC2NvbnRyaWJ1dG9yAAAAABMAAAABAAAAAAAAAA1vdmVyYWxsX3Njb3JlAAAAAAAABAAAAAAAAAAAAAAABWxldmVsAAAAAAAABAAAAAAAAAAC', + 'AAAABQAAAAAAAAAAAAAADUZyYXVkUmVjb3JkZWQAAAAAAAABAAAADmZyYXVkX3JlY29yZGVkAAAAAAACAAAAAAAAAAtjb250cmlidXRvcgAAAAATAAAAAQAAAAAAAAANb3ZlcmFsbF9zY29yZQAAAAAAAAQAAAAAAAAAAg==', + 'AAAABQAAAAAAAAAAAAAADkNyZWRpdHNBd2FyZGVkAAAAAAABAAAAD2NyZWRpdHNfYXdhcmRlZAAAAAADAAAAAAAAAAR1c2VyAAAAEwAAAAEAAAAAAAAABmFtb3VudAAAAAAABAAAAAAAAAAAAAAACXJlbWFpbmluZwAAAAAAAAQAAAAAAAAAAg==', +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AA1Cb3VudHlDb250ZXN0AAAAAAAAAAAAAAAAAAALQm91bnR5U3BsaXQAAAAAAAAAAAAAAAAPQ3Jvd2RmdW5kUGxlZGdlAAAAAAAAAAAAAAAADkdyYW50TWlsZXN0b25lAAAAAAAAAAAAAAAAABJHcmFudFJldHJvc3BlY3RpdmUAAAAAAAAAAAAAAAAAE0dyYW50UUZNYXRjaGluZ1Bvb2wAAAAAAAAAAAAAAAANSGFja2F0aG9uTWFpbgAAAAAAAAAAAAAAAAAADkhhY2thdGhvblRyYWNrAAA=', + 'AAAAAgAAAFBJZGVudGlmaWVzIHdoaWNoIHBsYXRmb3JtIG1vZHVsZSBvd25zIGEgcmVzb3VyY2UgKGVzY3JvdyBwb29sLCBmZWUgcmVjb3JkLCBldGMuKQAAAAAAAAAKTW9kdWxlVHlwZQAAAAAABAAAAAAAAAAAAAAABkJvdW50eQAAAAAAAAAAAAAAAAAJQ3Jvd2RmdW5kAAAAAAAAAAAAAAAAAAAFR3JhbnQAAAAAAAAAAAAAAAAAAAlIYWNrYXRob24AAAA=', + 'AAAAAgAAAExTa2lsbC9hY3Rpdml0eSBjYXRlZ29yaWVzIHVzZWQgYWNyb3NzIHJlcHV0YXRpb24gc2NvcmluZyBhbmQgYm91bnR5IHRhZ2dpbmcuAAAAAAAAABBBY3Rpdml0eUNhdGVnb3J5AAAABQAAAAAAAAAAAAAAC0RldmVsb3BtZW50AAAAAAAAAAAAAAAABkRlc2lnbgAAAAAAAAAAAAAAAAAJTWFya2V0aW5nAAAAAAAAAAAAAAAAAAAIU2VjdXJpdHkAAAAAAAAAAAAAAAlDb21tdW5pdHkAAAA=', + ]), + options + ); + } + public readonly fromJSON = { + init: this.txFromJSON>, + upgrade: this.txFromJSON>, + can_apply: this.txFromJSON, + get_level: this.txFromJSON>, + get_credits: this.txFromJSON>, + get_profile: this.txFromJSON>, + init_profile: this.txFromJSON>, + record_fraud: this.txFromJSON>, + spend_credit: this.txFromJSON>, + try_recharge: this.txFromJSON>, + award_credits: this.txFromJSON>, + record_penalty: this.txFromJSON>, + restore_credit: this.txFromJSON>, + next_recharge_at: this.txFromJSON>, + record_completion: this.txFromJSON>, + meets_requirements: this.txFromJSON>, + record_abandonment: this.txFromJSON>, + add_community_bonus: this.txFromJSON>, + record_late_delivery: this.txFromJSON>, + set_profile_metadata: this.txFromJSON>, + add_authorized_module: this.txFromJSON>, + record_grant_received: this.txFromJSON>, + record_campaign_backed: this.txFromJSON>, + record_hackathon_result: this.txFromJSON>, + meets_skill_requirements: this.txFromJSON>, + remove_authorized_module: this.txFromJSON>, + }; +} diff --git a/lib/contracts/reputation-registry/tsconfig.json b/lib/contracts/reputation-registry/tsconfig.json new file mode 100644 index 00000000..d434bd44 --- /dev/null +++ b/lib/contracts/reputation-registry/tsconfig.json @@ -0,0 +1,96 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + /* Language and Environment */ + "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + /* Modules */ + "module": "NodeNext" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "nodenext" /* Specify how TypeScript looks up a file from a given module specifier. */, + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + /* Emit */ + "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./dist" /* Specify an output folder for all emitted files. */, + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + /* Interop Constraints */ + "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + // "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + // "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + /* Type Checking */ + // "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + "strict": true /* When type checking, take into account 'null' and 'undefined'. */, + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + }, + "include": ["src/*"] +} diff --git a/lib/contracts/transaction.ts b/lib/contracts/transaction.ts new file mode 100644 index 00000000..06d79604 --- /dev/null +++ b/lib/contracts/transaction.ts @@ -0,0 +1,74 @@ +import { TransactionBuilder, rpc as SorobanRpc } from '@stellar/stellar-sdk'; +import type { AssembledTransaction } from '@stellar/stellar-sdk/contract'; +import { getRpcUrl, getNetworkPassphrase } from './index'; + +/** + * Simulate a contract call and return the decoded result. + * Uses the contract client's built-in simulation via AssembledTransaction. + */ +export async function simulateContract( + tx: AssembledTransaction +): Promise { + await tx.simulate(); + return tx.result; +} + +/** + * Build an unsigned transaction XDR from an AssembledTransaction. + * Simulates the transaction to populate Soroban data (footprint, auth entries), + * then returns the XDR ready for wallet signing. + */ +export async function buildTransaction( + tx: AssembledTransaction +): Promise { + await tx.simulate(); + return tx.toXDR(); +} + +export interface SubmitTransactionResult { + hash: string; + getResponse: SorobanRpc.Api.GetTransactionResponse; +} + +/** + * Submit a signed transaction XDR to the network. + * Polls until confirmed or until maxWaitSeconds is reached. + * Returns the hash and the final GetTransactionResponse so callers + * can access write-method return values. + */ +export async function submitTransaction( + signedXdr: string, + maxWaitSeconds = 30 +): Promise { + const server = new SorobanRpc.Server(getRpcUrl()); + + const sendResponse = await server.sendTransaction( + TransactionBuilder.fromXDR(signedXdr, getNetworkPassphrase()) + ); + + if (sendResponse.status === 'ERROR') { + throw new Error( + `Transaction submission failed: ${JSON.stringify(sendResponse.errorResult)}` + ); + } + + const hash = sendResponse.hash; + const deadline = Date.now() + maxWaitSeconds * 1000; + let getResponse = await server.getTransaction(hash); + + while (getResponse.status === SorobanRpc.Api.GetTransactionStatus.NOT_FOUND) { + if (Date.now() > deadline) { + throw new Error( + `Transaction ${hash} not confirmed within ${maxWaitSeconds}s` + ); + } + await new Promise(resolve => setTimeout(resolve, 1000)); + getResponse = await server.getTransaction(hash); + } + + if (getResponse.status === SorobanRpc.Api.GetTransactionStatus.FAILED) { + throw new Error(`Transaction failed: ${hash}`); + } + + return { hash, getResponse }; +}