diff --git a/.gitignore b/.gitignore index 18a437b..3905b4f 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,7 @@ src/data-import/data/users.csv .vercel .tool-versions + +contract/target +contract/.vars +.soroban diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz index c570f5c..c251b2e 100644 Binary files a/.yarn/install-state.gz and b/.yarn/install-state.gz differ diff --git a/contract-client/.gitignore b/contract-client/.gitignore new file mode 100644 index 0000000..72aae85 --- /dev/null +++ b/contract-client/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +out/ diff --git a/contract-client/README.md b/contract-client/README.md new file mode 100644 index 0000000..1def30d --- /dev/null +++ b/contract-client/README.md @@ -0,0 +1,54 @@ +# contract-client JS + +JS library for interacting with [Soroban](https://soroban.stellar.org/) smart contract `contract-client` 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 CC5ELPSQFQMJ75XUPJARIODNA7UIH4RS36N37BAV4SVEBEDN4PJYVL5E \ + --output-dir ./path/to/contract-client +``` + +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": { + "contract-client": "./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 CC5ELPSQFQMJ75XUPJARIODNA7UIH4RS36N37BAV4SVEBEDN4PJYVL5E --name contract-client" +} +``` + +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 "contract-client" + +const contract = new Contract({ + ...networks.futurenet, // 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/contract-client/dist/index.d.ts b/contract-client/dist/index.d.ts new file mode 100644 index 0000000..fbd3758 --- /dev/null +++ b/contract-client/dist/index.d.ts @@ -0,0 +1,134 @@ +import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions } from '@stellar/stellar-sdk/contract'; +import type { i128 } 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'; +export declare const networks: { + readonly testnet: { + readonly networkPassphrase: "Test SDF Network ; September 2015"; + readonly contractId: "CC5ELPSQFQMJ75XUPJARIODNA7UIH4RS36N37BAV4SVEBEDN4PJYVL5E"; + }; +}; +export type DataKey = { + tag: "Index"; + values: void; +} | { + tag: "Entries"; + values: readonly [string]; +}; +export interface Entry { + apr: i128; + equity_shares: Map; + escrow: i128; + ipfs_hash: string; + total_invested: i128; +} +export declare const Errors: {}; +export interface Client { + /** + * Construct and simulate a set_entry 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_entry: ({ entry }: { + entry: Entry; + }, options?: { + /** + * The fee to pay for the transaction. Default: BASE_FEE + */ + fee?: number; + /** + * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT + */ + timeoutInSeconds?: number; + /** + * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true + */ + simulate?: boolean; + }) => Promise>; + /** + * Construct and simulate a get_entry 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_entry: ({ ipfs_hash }: { + ipfs_hash: string; + }, options?: { + /** + * The fee to pay for the transaction. Default: BASE_FEE + */ + fee?: number; + /** + * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT + */ + timeoutInSeconds?: number; + /** + * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true + */ + simulate?: boolean; + }) => Promise>; + /** + * Construct and simulate a invest 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. + */ + invest: ({ user, ipfs_hash, amount }: { + user: string; + ipfs_hash: string; + amount: i128; + }, options?: { + /** + * The fee to pay for the transaction. Default: BASE_FEE + */ + fee?: number; + /** + * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT + */ + timeoutInSeconds?: number; + /** + * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true + */ + simulate?: boolean; + }) => Promise>; + /** + * Construct and simulate a distribute_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. + */ + distribute_payout: ({ ipfs_hash }: { + ipfs_hash: string; + }, options?: { + /** + * The fee to pay for the transaction. Default: BASE_FEE + */ + fee?: number; + /** + * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT + */ + timeoutInSeconds?: number; + /** + * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true + */ + simulate?: boolean; + }) => Promise>; + /** + * Construct and simulate a distribute_payouts 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. + */ + distribute_payouts: (options?: { + /** + * The fee to pay for the transaction. Default: BASE_FEE + */ + fee?: number; + /** + * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT + */ + timeoutInSeconds?: number; + /** + * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true + */ + simulate?: boolean; + }) => Promise>; +} +export declare class Client extends ContractClient { + readonly options: ContractClientOptions; + constructor(options: ContractClientOptions); + readonly fromJSON: { + set_entry: (json: string) => AssembledTransaction; + get_entry: (json: string) => AssembledTransaction; + invest: (json: string) => AssembledTransaction; + distribute_payout: (json: string) => AssembledTransaction; + distribute_payouts: (json: string) => AssembledTransaction; + }; +} diff --git a/contract-client/dist/index.js b/contract-client/dist/index.js new file mode 100644 index 0000000..964e107 --- /dev/null +++ b/contract-client/dist/index.js @@ -0,0 +1,36 @@ +import { Buffer } from "buffer"; +import { Client as ContractClient, Spec as ContractSpec, } 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: "CC5ELPSQFQMJ75XUPJARIODNA7UIH4RS36N37BAV4SVEBEDN4PJYVL5E", + } +}; +export const Errors = {}; +export class Client extends ContractClient { + options; + constructor(options) { + super(new ContractSpec(["AAAAAgAAAAAAAAAAAAAAB0RhdGFLZXkAAAAAAgAAAAAAAAAAAAAABUluZGV4AAAAAAAAAQAAAAAAAAAHRW50cmllcwAAAAABAAAAEA==", + "AAAAAQAAAAAAAAAAAAAABUVudHJ5AAAAAAAABQAAAAAAAAADYXByAAAAAAsAAAAAAAAADWVxdWl0eV9zaGFyZXMAAAAAAAPsAAAAEwAAAAsAAAAAAAAABmVzY3JvdwAAAAAACwAAAAAAAAAJaXBmc19oYXNoAAAAAAAAEAAAAAAAAAAOdG90YWxfaW52ZXN0ZWQAAAAAAAs=", + "AAAAAAAAAAAAAAAJc2V0X2VudHJ5AAAAAAAAAQAAAAAAAAAFZW50cnkAAAAAAAfQAAAABUVudHJ5AAAAAAAAAA==", + "AAAAAAAAAAAAAAAJZ2V0X2VudHJ5AAAAAAAAAQAAAAAAAAAJaXBmc19oYXNoAAAAAAAAEAAAAAEAAAfQAAAABUVudHJ5AAAA", + "AAAAAAAAAAAAAAAGaW52ZXN0AAAAAAADAAAAAAAAAAR1c2VyAAAAEwAAAAAAAAAJaXBmc19oYXNoAAAAAAAAEAAAAAAAAAAGYW1vdW50AAAAAAALAAAAAA==", + "AAAAAAAAAAAAAAARZGlzdHJpYnV0ZV9wYXlvdXQAAAAAAAABAAAAAAAAAAlpcGZzX2hhc2gAAAAAAAAQAAAAAA==", + "AAAAAAAAAAAAAAASZGlzdHJpYnV0ZV9wYXlvdXRzAAAAAAAAAAAAAA=="]), options); + this.options = options; + } + fromJSON = { + set_entry: (this.txFromJSON), + get_entry: (this.txFromJSON), + invest: (this.txFromJSON), + distribute_payout: (this.txFromJSON), + distribute_payouts: (this.txFromJSON) + }; +} diff --git a/contract-client/package-lock.json b/contract-client/package-lock.json new file mode 100644 index 0000000..e75390e --- /dev/null +++ b/contract-client/package-lock.json @@ -0,0 +1,328 @@ +{ + "name": "contract-client", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "contract-client", + "version": "0.0.0", + "dependencies": { + "@stellar/freighter-api": "2.0.0", + "@stellar/stellar-sdk": "12.0.0-rc.3", + "buffer": "6.0.3" + }, + "devDependencies": { + "typescript": "5.3.3" + } + }, + "node_modules/@stellar/freighter-api": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@stellar/freighter-api/-/freighter-api-2.0.0.tgz", + "integrity": "sha512-j/R7MLPL8S3QhwOEdAxSl7MgWBTXWlOXQKQyXR8mPk1JMKKR4tF8e4U+Fs9TPQH0HZoYqfVDvLOOUrTMMY058Q==" + }, + "node_modules/@stellar/js-xdr": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@stellar/js-xdr/-/js-xdr-3.1.1.tgz", + "integrity": "sha512-3gnPjAz78htgqsNEDkEsKHKosV2BF2iZkoHCNxpmZwUxiPsw+2VaXMed8RRMe0rGk3d5GZe7RrSba8zV80J3Ag==" + }, + "node_modules/@stellar/stellar-base": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/@stellar/stellar-base/-/stellar-base-12.0.0.tgz", + "integrity": "sha512-uGpahDFFXbE39myOmBnEZSjVys4yUkQ/ASNuYENGyS8MNdfA0TS7DPWkiO6t17P+rW+FRV1zmumJtjRHwxxMdw==", + "dependencies": { + "@stellar/js-xdr": "^3.1.1", + "base32.js": "^0.1.0", + "bignumber.js": "^9.1.2", + "buffer": "^6.0.3", + "sha.js": "^2.3.6", + "tweetnacl": "^1.0.3" + }, + "optionalDependencies": { + "sodium-native": "^4.1.1" + } + }, + "node_modules/@stellar/stellar-sdk": { + "version": "12.0.0-rc.3", + "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-12.0.0-rc.3.tgz", + "integrity": "sha512-FYO+F8VokXjP3Mu+OQtK0GrJWWvwf1+DL3n3aOi6M5H6EwJ6bp/yAOtfnClx6vqzzvpMbWveYABn8U9QNpcHww==", + "dependencies": { + "@stellar/stellar-base": "^12.0.0-rc.1", + "axios": "^1.6.8", + "bignumber.js": "^9.1.2", + "eventsource": "^2.0.2", + "randombytes": "^2.1.0", + "toml": "^3.0.0", + "urijs": "^1.19.1" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/base32.js": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base32.js/-/base32.js-0.1.0.tgz", + "integrity": "sha512-n3TkB02ixgBOhTvANakDb4xaMXnYUVkNoRFJjQflcqMQhyEKxEHdj3E6N8t8sUQ0mjH/3/JxzlXuz3ul/J90pQ==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bignumber.js": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", + "engines": { + "node": "*" + } + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/eventsource": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-2.0.2.tgz", + "integrity": "sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-gyp-build": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.1.tgz", + "integrity": "sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==", + "optional": true, + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" + } + }, + "node_modules/sodium-native": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-4.1.1.tgz", + "integrity": "sha512-LXkAfRd4FHtkQS4X6g+nRcVaN7mWVNepV06phIsC6+IZFvGh1voW5TNQiQp2twVaMf05gZqQjuS+uWLM6gHhNQ==", + "hasInstallScript": true, + "optional": true, + "dependencies": { + "node-gyp-build": "^4.8.0" + } + }, + "node_modules/toml": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", + "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" + }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + }, + "node_modules/typescript": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/urijs": { + "version": "1.19.11", + "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.11.tgz", + "integrity": "sha512-HXgFDgDommxn5/bIv0cnQZsPhHDA90NPHD6+c/v21U5+Sx5hoP8+dP9IZXBU1gIfvdRfhG8cel9QNPeionfcCQ==" + } + } +} diff --git a/contract-client/package.json b/contract-client/package.json new file mode 100644 index 0000000..3221bc1 --- /dev/null +++ b/contract-client/package.json @@ -0,0 +1,18 @@ +{ + "version": "0.0.0", + "name": "contract-client", + "type": "module", + "exports": "./dist/index.js", + "typings": "dist/index.d.ts", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "@stellar/freighter-api": "2.0.0", + "buffer": "6.0.3", + "@stellar/stellar-sdk": "12.0.0-rc.3" + }, + "devDependencies": { + "typescript": "5.3.3" + } +} diff --git a/contract-client/src/index.ts b/contract-client/src/index.ts new file mode 100644 index 0000000..eeb1410 --- /dev/null +++ b/contract-client/src/index.ts @@ -0,0 +1,177 @@ +import { Buffer } from "buffer"; +import { Address } from '@stellar/stellar-sdk'; +import { + AssembledTransaction, + Client as ContractClient, + ClientOptions as ContractClientOptions, + Result, + Spec as ContractSpec, +} from '@stellar/stellar-sdk/contract'; +import type { + u32, + i32, + u64, + i64, + u128, + i128, + u256, + i256, + Option, + Typepoint, + Duration, +} 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: "CC5ELPSQFQMJ75XUPJARIODNA7UIH4RS36N37BAV4SVEBEDN4PJYVL5E", + } +} as const + +export type DataKey = {tag: "Index", values: void} | {tag: "Entries", values: readonly [string]}; + + +export interface Entry { + apr: i128; + equity_shares: Map; + escrow: i128; + ipfs_hash: string; + total_invested: i128; +} + +export const Errors = { + +} + +export interface Client { + /** + * Construct and simulate a set_entry 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_entry: ({entry}: {entry: Entry}, options?: { + /** + * The fee to pay for the transaction. Default: BASE_FEE + */ + fee?: number; + + /** + * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT + */ + timeoutInSeconds?: number; + + /** + * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true + */ + simulate?: boolean; + }) => Promise> + + /** + * Construct and simulate a get_entry 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_entry: ({ipfs_hash}: {ipfs_hash: string}, options?: { + /** + * The fee to pay for the transaction. Default: BASE_FEE + */ + fee?: number; + + /** + * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT + */ + timeoutInSeconds?: number; + + /** + * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true + */ + simulate?: boolean; + }) => Promise> + + /** + * Construct and simulate a invest 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. + */ + invest: ({user, ipfs_hash, amount}: {user: string, ipfs_hash: string, amount: i128}, options?: { + /** + * The fee to pay for the transaction. Default: BASE_FEE + */ + fee?: number; + + /** + * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT + */ + timeoutInSeconds?: number; + + /** + * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true + */ + simulate?: boolean; + }) => Promise> + + /** + * Construct and simulate a distribute_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. + */ + distribute_payout: ({ipfs_hash}: {ipfs_hash: string}, options?: { + /** + * The fee to pay for the transaction. Default: BASE_FEE + */ + fee?: number; + + /** + * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT + */ + timeoutInSeconds?: number; + + /** + * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true + */ + simulate?: boolean; + }) => Promise> + + /** + * Construct and simulate a distribute_payouts 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. + */ + distribute_payouts: (options?: { + /** + * The fee to pay for the transaction. Default: BASE_FEE + */ + fee?: number; + + /** + * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT + */ + timeoutInSeconds?: number; + + /** + * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true + */ + simulate?: boolean; + }) => Promise> + +} +export class Client extends ContractClient { + constructor(public readonly options: ContractClientOptions) { + super( + new ContractSpec([ "AAAAAgAAAAAAAAAAAAAAB0RhdGFLZXkAAAAAAgAAAAAAAAAAAAAABUluZGV4AAAAAAAAAQAAAAAAAAAHRW50cmllcwAAAAABAAAAEA==", + "AAAAAQAAAAAAAAAAAAAABUVudHJ5AAAAAAAABQAAAAAAAAADYXByAAAAAAsAAAAAAAAADWVxdWl0eV9zaGFyZXMAAAAAAAPsAAAAEwAAAAsAAAAAAAAABmVzY3JvdwAAAAAACwAAAAAAAAAJaXBmc19oYXNoAAAAAAAAEAAAAAAAAAAOdG90YWxfaW52ZXN0ZWQAAAAAAAs=", + "AAAAAAAAAAAAAAAJc2V0X2VudHJ5AAAAAAAAAQAAAAAAAAAFZW50cnkAAAAAAAfQAAAABUVudHJ5AAAAAAAAAA==", + "AAAAAAAAAAAAAAAJZ2V0X2VudHJ5AAAAAAAAAQAAAAAAAAAJaXBmc19oYXNoAAAAAAAAEAAAAAEAAAfQAAAABUVudHJ5AAAA", + "AAAAAAAAAAAAAAAGaW52ZXN0AAAAAAADAAAAAAAAAAR1c2VyAAAAEwAAAAAAAAAJaXBmc19oYXNoAAAAAAAAEAAAAAAAAAAGYW1vdW50AAAAAAALAAAAAA==", + "AAAAAAAAAAAAAAARZGlzdHJpYnV0ZV9wYXlvdXQAAAAAAAABAAAAAAAAAAlpcGZzX2hhc2gAAAAAAAAQAAAAAA==", + "AAAAAAAAAAAAAAASZGlzdHJpYnV0ZV9wYXlvdXRzAAAAAAAAAAAAAA==" ]), + options + ) + } + public readonly fromJSON = { + set_entry: this.txFromJSON, + get_entry: this.txFromJSON, + invest: this.txFromJSON, + distribute_payout: this.txFromJSON, + distribute_payouts: this.txFromJSON + } +} \ No newline at end of file diff --git a/contract-client/tsconfig.json b/contract-client/tsconfig.json new file mode 100644 index 0000000..3841393 --- /dev/null +++ b/contract-client/tsconfig.json @@ -0,0 +1,97 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + /* 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. */ + "strictNullChecks": 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/contract/Cargo.lock b/contract/Cargo.lock new file mode 100644 index 0000000..c16e100 --- /dev/null +++ b/contract/Cargo.lock @@ -0,0 +1,1465 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base32" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "bytes-lit" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0adabf37211a5276e46335feabcbb1530c95eb3fdf85f324c7db942770aa025d" +dependencies = [ + "num-bigint", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "cc" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crate-git-revision" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c521bf1f43d31ed2f73441775ed31935d77901cb3451e44b38a1c1612fcbaf98" +dependencies = [ + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "ctor" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "platforms", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "darling" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "ecdsa" +version = "0.16.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" +dependencies = [ + "der", + "digest", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand_core", + "serde", + "sha2", + "zeroize", +] + +[[package]] +name = "either" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest", + "ff", + "generic-array", + "group", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "escape-bytes" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bfcf67fea2815c2fc3b90873fae90957be12ff417335dfadc7f52927feb03b2" + +[[package]] +name = "ethnum" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c" + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", + "serde", +] + +[[package]] +name = "indexmap-nostd" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "miniz_oxide" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +dependencies = [ + "adler", +] + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-derive" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "platforms" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db23d408679286588f4d4644f965003d056e3dd5abcaaa938116871d7ce2fee7" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "prettyplease" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "proc-macro2" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "sec1" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" +dependencies = [ + "base16ct", + "der", + "generic-array", + "subtle", + "zeroize", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.2.6", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "skyhitz" +version = "0.1.0" +dependencies = [ + "soroban-sdk", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "soroban-builtin-sdk-macros" +version = "21.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "084aab008009e712c445a9d7eab837a86559a6c2341f30bc4f33e9b258947688" +dependencies = [ + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "soroban-env-common" +version = "21.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c16ee889fe99d6828bf3ffac00c84382793c31d62682401dbfa3e1b512f0c542" +dependencies = [ + "arbitrary", + "crate-git-revision", + "ethnum", + "num-derive", + "num-traits", + "serde", + "soroban-env-macros", + "soroban-wasmi", + "static_assertions", + "stellar-xdr", + "wasmparser", +] + +[[package]] +name = "soroban-env-guest" +version = "21.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95e591a15e488e66d3edd4be044fc4ffea438945f022c27129e933275744666f" +dependencies = [ + "soroban-env-common", + "static_assertions", +] + +[[package]] +name = "soroban-env-host" +version = "21.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b73f48ae8081ecfb6c0d56c67f139c52cb6d5b6800d5e1adb9eef8e14a155b9" +dependencies = [ + "backtrace", + "curve25519-dalek", + "ecdsa", + "ed25519-dalek", + "elliptic-curve", + "generic-array", + "getrandom", + "hex-literal", + "hmac", + "k256", + "num-derive", + "num-integer", + "num-traits", + "p256", + "rand", + "rand_chacha", + "sec1", + "sha2", + "sha3", + "soroban-builtin-sdk-macros", + "soroban-env-common", + "soroban-wasmi", + "static_assertions", + "stellar-strkey", + "wasmparser", +] + +[[package]] +name = "soroban-env-macros" +version = "21.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06d0581e3aba14892ee0ce63788f3d3e5d9eb1ab18906a9b7c66d77dae9e9fea" +dependencies = [ + "itertools", + "proc-macro2", + "quote", + "serde", + "serde_json", + "stellar-xdr", + "syn", +] + +[[package]] +name = "soroban-ledger-snapshot" +version = "21.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07d02fc89d3a0e49776cdc35609719ddc5635ff61751b37d5577a06cc4b592ea" +dependencies = [ + "serde", + "serde_json", + "serde_with", + "soroban-env-common", + "soroban-env-host", + "thiserror", +] + +[[package]] +name = "soroban-sdk" +version = "21.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1460cfdb31c0a1a7b93a35573fb9f794244a196224f8bf94cd235e4d29d8563d" +dependencies = [ + "arbitrary", + "bytes-lit", + "ctor", + "ed25519-dalek", + "rand", + "serde", + "serde_json", + "soroban-env-guest", + "soroban-env-host", + "soroban-ledger-snapshot", + "soroban-sdk-macros", + "stellar-strkey", +] + +[[package]] +name = "soroban-sdk-macros" +version = "21.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a164fe430678986174b9872c6f82c23d73e74d3c6820800979af19c455c0bb70" +dependencies = [ + "crate-git-revision", + "darling", + "itertools", + "proc-macro2", + "quote", + "rustc_version", + "sha2", + "soroban-env-common", + "soroban-spec", + "soroban-spec-rust", + "stellar-xdr", + "syn", +] + +[[package]] +name = "soroban-spec" +version = "21.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eeac587846418ecb0c73e9b05a9719559bccfc05da941d328eb3f8f8664c11a" +dependencies = [ + "base64 0.13.1", + "stellar-xdr", + "thiserror", + "wasmparser", +] + +[[package]] +name = "soroban-spec-rust" +version = "21.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c179749d655418a01d6d46d5dd08c024ed2e6ee68689430144195ba2f42ca8" +dependencies = [ + "prettyplease", + "proc-macro2", + "quote", + "sha2", + "soroban-spec", + "stellar-xdr", + "syn", + "thiserror", +] + +[[package]] +name = "soroban-wasmi" +version = "0.31.1-soroban.20.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "710403de32d0e0c35375518cb995d4fc056d0d48966f2e56ea471b8cb8fc9719" +dependencies = [ + "smallvec", + "spin", + "wasmi_arena", + "wasmi_core", + "wasmparser-nostd", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "stellar-strkey" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12d2bf45e114117ea91d820a846fd1afbe3ba7d717988fee094ce8227a3bf8bd" +dependencies = [ + "base32", + "crate-git-revision", + "thiserror", +] + +[[package]] +name = "stellar-xdr" +version = "21.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec43c9c5ae7ec7b6ac9e263b6d5b9e3781aa05ba3a1c05f6e70701c5c6600665" +dependencies = [ + "arbitrary", + "base64 0.13.1", + "crate-git-revision", + "escape-bytes", + "hex", + "serde", + "serde_with", + "stellar-strkey", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3de26b0965292219b4287ff031fcba86837900fe9cd2b34ea8ad893c0953d2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "268026685b2be38d7103e9e507c938a1fcb3d7e6eb15e87870b617bf37b6d581" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "wasmi_arena" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "104a7f73be44570cac297b3035d76b169d6599637631cf37a1703326a0727073" + +[[package]] +name = "wasmi_core" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf1a7db34bff95b85c261002720c00c3a6168256dcb93041d3fa2054d19856a" +dependencies = [ + "downcast-rs", + "libm", + "num-traits", + "paste", +] + +[[package]] +name = "wasmparser" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a58e28b80dd8340cb07b8242ae654756161f6fc8d0038123d679b7b99964fa50" +dependencies = [ + "indexmap 2.2.6", + "semver", +] + +[[package]] +name = "wasmparser-nostd" +version = "0.100.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5a015fe95f3504a94bb1462c717aae75253e39b9dd6c3fb1062c934535c64aa" +dependencies = [ + "indexmap-nostd", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/contract/Cargo.toml b/contract/Cargo.toml new file mode 100644 index 0000000..11bbc1d --- /dev/null +++ b/contract/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "skyhitz" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +soroban-sdk = "21.1.0-rc.1" + +[dev_dependencies] +soroban-sdk = { version = "21.1.0-rc.1", features = ["testutils"] } + +[features] +testutils = ["soroban-sdk/testutils"] + +[profile.release] +opt-level = "z" +overflow-checks = true +debug = 0 +strip = "symbols" +debug-assertions = false +panic = "abort" +codegen-units = 1 +lto = true + +[profile.release-with-logs] +inherits = "release" +debug-assertions = true diff --git a/contract/init.sh b/contract/init.sh new file mode 100755 index 0000000..17e9df4 --- /dev/null +++ b/contract/init.sh @@ -0,0 +1,136 @@ +#!/bin/bash + +set -e + +NETWORK="$1" + +SOROBAN_RPC_HOST="$2" + +CTR="contract-id" + +PATH=./target/bin:$PATH + +cd ./contract + +if [[ -f "./.vars/$CTR" ]]; then + echo "Found existing contract directory; already initialized." + exit 0 +fi + + +if [[ "$SOROBAN_RPC_HOST" == "" ]]; then + # If soroban-cli is called inside the soroban-preview docker container, + # it can call the stellar standalone container just using its name "stellar" + if [[ "$IS_USING_DOCKER" == "true" ]]; then + SOROBAN_RPC_HOST="http://stellar:8000" + SOROBAN_RPC_URL="$SOROBAN_RPC_HOST" + FRIENDBOT_URL="http://localhost:8000/friendbot" + elif [[ "$NETWORK" == "futurenet" ]]; then + SOROBAN_RPC_HOST="https://rpc-futurenet.stellar.org:443" + SOROBAN_RPC_URL="$SOROBAN_RPC_HOST" + FRIENDBOT_URL="https://friendbot-futurenet.stellar.org" + elif [[ "$NETWORK" == "testnet" ]]; then + SOROBAN_RPC_HOST="https://soroban-testnet.stellar.org:443" + SOROBAN_RPC_URL="$SOROBAN_RPC_HOST" + FRIENDBOT_URL="https://friendbot.stellar.org" + else + # assumes standalone on quickstart, which has the soroban/rpc path + SOROBAN_RPC_HOST="http://localhost:8000" + SOROBAN_RPC_URL="$SOROBAN_RPC_HOST/soroban/rpc" + FRIENDBOT_URL="http://localhost:8000/friendbot" + fi +else + SOROBAN_RPC_URL="$SOROBAN_RPC_HOST" +fi + +case "$1" in +standalone) + SOROBAN_NETWORK_PASSPHRASE="Standalone Network ; February 2017" + FRIENDBOT_URL="$SOROBAN_RPC_HOST/friendbot" + ;; +futurenet) + SOROBAN_NETWORK_PASSPHRASE="Test SDF Future Network ; October 2022" + FRIENDBOT_URL="https://friendbot-futurenet.stellar.org/" + ;; +testnet) + SOROBAN_NETWORK_PASSPHRASE="Test SDF Network ; September 2015" + FRIENDBOT_URL="https://friendbot.stellar.org" + ;; +*) + echo "Usage: $0 standalone|futurenet|testnet [rpc-host]" + exit 1 + ;; +esac + +echo "Using $NETWORK network" +echo " RPC URL: $SOROBAN_RPC_URL" +echo " Friendbot URL: $FRIENDBOT_URL" + +echo Add the $NETWORK network to cli client +soroban network add \ + --rpc-url "$SOROBAN_RPC_URL" \ + --network-passphrase "$SOROBAN_NETWORK_PASSPHRASE" "$NETWORK" + +echo Add $NETWORK to .vars for use with npm scripts +mkdir -p .vars +echo $NETWORK > ./.vars/network +echo -n $SOROBAN_RPC_URL > ./.vars/rpc-url +echo -n "$SOROBAN_NETWORK_PASSPHRASE" > ./.vars/passphrase +echo $FRIENDBOT_URL > ./.vars/friendbot-url + +echo -n GD7BAZM73BXQTMRHA2JVJPE5X4AATOMOIXGA76N22JNTNMVXRQW5DR4B > ./.vars/public-key +echo -n SB6NGNDLFKMRK4XW2W5OWFMJ2LIJ5SBXJU2X5TRSPXR2UNDOXHHZNKWY > ./.vars/secret-key + +if !(soroban keys ls | grep token-admin 2>&1 >/dev/null); then + echo Create the token-admin identity + soroban keys generate token-admin --rpc-url "$SOROBAN_RPC_URL" --network-passphrase "$SOROBAN_NETWORK_PASSPHRASE" --network "$NETWORK" +fi +ADMIN_ADDRESS="$(soroban keys address token-admin)" + +# This will fail if the account already exists, but it'll still be fine. +echo Fund token-admin account from friendbot +curl --silent -X POST "$FRIENDBOT_URL?addr=$ADMIN_ADDRESS" >/dev/null + +ARGS="--network $NETWORK --source token-admin" + +echo Install dependencies + +yarn + +echo Build contracts + +soroban contract build + +# echo Deploy the voting contracts +echo Deploy contract $CTR + DEPLOYED_CTR_ID="$( + soroban contract deploy $ARGS \ + --wasm ./target/wasm32-unknown-unknown/release/skyhitz.wasm + )" + echo "Contract deployed succesfully with ID: $DEPLOYED_CTR_ID" + echo -n "$DEPLOYED_CTR_ID" > .vars/$CTR + + # we do not use bindings for now but they're sometimes useful - they contain a lot of code that interacts with blockchain + # plus we may switch to using them one day + # echo Build Bindings for $CTR + soroban contract bindings typescript \ + --wasm ./target/wasm32-unknown-unknown/release/skyhitz.wasm \ + --output-dir ../contract-client \ + --network $(cat ./.vars/network) \ + --contract-id $(cat ./.vars/$CTR) \ + --overwrite + +cd ../ + +yarn add ./contract-client + +echo "Change development vercel variables" +vercel env rm RPC_URL development --yes 2> /dev/null || true +vercel env rm NETWORK_PASSPHRASE development --yes 2> /dev/null || true +vercel env rm CONTRACT_ID development --yes 2> /dev/null || true +vercel env rm CONTRACT_SECRET development --yes 2> /dev/null || true +vercel env add RPC_URL development < ./contract/.vars/rpc-url +vercel env add NETWORK_PASSPHRASE development < ./contract/.vars/passphrase +vercel env add CONTRACT_ID development < ./contract/.vars/contract-id +vercel env add CONTRACT_SECRET development < ./contract/.vars/secret-key + diff --git a/contract/src/lib.rs b/contract/src/lib.rs new file mode 100644 index 0000000..b8cea11 --- /dev/null +++ b/contract/src/lib.rs @@ -0,0 +1,115 @@ +#![no_std] + +use soroban_sdk::{contract, contracttype, Map, contractimpl, Env, String, Address, token, log, Vec, vec }; + +#[contracttype] +pub enum DataKey { + Index, + Entries(String), +} + +#[contracttype] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Entry { + pub ipfs_hash: String, + pub apr: i128, + pub total_invested: i128, + pub escrow: i128, + pub equity_shares: Map, +} + +#[contract] +pub struct Contract; + +#[contractimpl] +impl Contract { + pub fn set_entry(e: Env, entry: Entry) { + let key = DataKey::Entries(entry.ipfs_hash.clone()); + e.storage().instance().set(&key, &entry); + + let mut index: Vec = e.storage().instance().get(&DataKey::Index).unwrap_or(vec![&e]); + index.push_back(entry.ipfs_hash.clone()); + e.storage().instance().set(&DataKey::Index, &index); + } + + + pub fn get_entry(e: &Env, ipfs_hash: String) -> Entry { + let key = DataKey::Entries(ipfs_hash); + + e.storage().instance().get(&key).unwrap() + } + + pub fn invest(e: Env, user: Address, ipfs_hash: String, amount: i128) { + user.require_auth(); + let download_amount = 3000000; + let key = DataKey::Entries(ipfs_hash.clone()); + let mut entry: Entry = e.storage().instance().get(&key).unwrap(); + + // Update equity share + let past_user_equity = entry.equity_shares.get(user.clone()).unwrap_or(0); + + if amount > download_amount { + entry.equity_shares.set(user.clone(), past_user_equity + amount); + log!(&e, "Got equity!"); + entry.total_invested += amount; + } + + entry.escrow += amount; + entry.apr = get_apr(&e, entry.clone()); + + // Save updated entry + e.storage().instance().set(&key, &entry); + transfer(&e, &user, &e.current_contract_address(), amount); + } + + pub fn distribute_payout(e: Env, ipfs_hash: String) { + let key = DataKey::Entries(ipfs_hash.clone()); + let mut entry: Entry = e.storage().instance().get(&key).unwrap(); + for (user, equity) in entry.equity_shares.iter() { + let user_payout = (entry.escrow / 365) * (equity / entry.total_invested); + entry.escrow -= user_payout; + entry.apr = get_apr(&e, entry.clone()); + + e.storage().instance().set(&key, &entry); + log!(&e, "Payout {}!", user_payout); + transfer(&e, &e.current_contract_address(), &user, user_payout); + } + } + + pub fn distribute_payouts(e: Env) { + let index: Vec = e.storage().instance().get(&DataKey::Index).unwrap_or(vec![&e]); + for key in index.iter() { + // Access each entry by key + log!(&e,"Key: {}", key); + Self::distribute_payout(e.clone(), key); + } + } + +} + +fn get_apr(_: &Env, entry: Entry) -> i128 { + if entry.total_invested == 0 { + return 0 + } + (entry.escrow * 100 ) / entry.total_invested +} + +fn transfer(e: &Env, from: &Address, to: &Address, amount: i128) { + let token_contract_id = &get_xlm_address(e); + let client = token::Client::new(e, token_contract_id); + client.transfer(from, to, &amount) +} + +fn get_xlm_address(env: &Env) -> Address { + + // futurenet + // CB64D3G7SM2RTH6JSGG34DDTFTQ5CFDKVDZJZSODMCX4NJ2HV2KN7OHT + // testnet + // CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC + // mainnet + // CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA + + // testnet + Address::from_string(&String::from_str(env, "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC",)) +} + diff --git a/package.json b/package.json index 441b4bf..17e29e0 100644 --- a/package.json +++ b/package.json @@ -4,23 +4,27 @@ "main": "index.ts", "author": "Alejo Mendoza", "license": "MIT", + "type": "module", "scripts": { "dev": "NODE_ENV=development node -r ts-node/register -r tsconfig-paths/register --inspect ./src/graphql/server.ts", "prod": "NODE_ENV=production node -r ts-node/register -r tsconfig-paths/register --inspect ./src/graphql/server.ts", "ci": "tsc --noEmit && tslint --test src && prettier --check src", - "stellar:check-test-account": "node -r ts-node/register ./src/testing/verify-stellar-test-account.ts" + "stellar:check-test-account": "node -r ts-node/register ./src/testing/verify-stellar-test-account.ts", + "setup": "./contract/init.sh ${NETWORK:-testnet}" }, "dependencies": { - "@apollo/server": "^4.2.0", + "@apollo/server": "^4.10.4", "@iarna/toml": "^2.2.5", "@sendgrid/mail": "^7.7.0", + "@stellar/js-xdr": "^3.1.0", + "@stellar/stellar-sdk": "12.0.0-rc.3", "@types/cors": "^2.8.12", "@types/express-jwt": "^6.0.4", "@types/graphql": "^14.2.3", "@types/jsonwebtoken": "^8.5.9", "algoliasearch": "^4.14.2", "async": "^3.2.4", - "axios": "1.1.0", + "axios": "^1.7.2", "axios-cache-adapter": "^2.7.3", "bcrypt": "5.1.0", "body-parser": "^1.20.1", @@ -31,6 +35,7 @@ "express": "^4.18.2", "express-jwt": "^7.7.7", "graphql": "^16.6.0", + "graphql-type-json": "^0.3.2", "jsonwebtoken": "^8.5.1", "memory-cache": "^0.2.0", "sha.js": "^2.4.11", @@ -41,10 +46,10 @@ "devDependencies": { "@vercel/node": "2.4.0", "prettier": "2.8.0", - "ts-node": "^10.9.1", + "ts-node": "^10.9.2", "tsconfig-paths": "^4.1.0", "tslint": "^6.1.2", - "typescript": "^4.9.3" + "typescript": "^5.4.5" }, "packageManager": "yarn@4.1.1" } diff --git a/src/config/config.interface.ts b/src/config/config.interface.ts index 500fcfd..8b117d4 100644 --- a/src/config/config.interface.ts +++ b/src/config/config.interface.ts @@ -9,7 +9,6 @@ export interface IConfig { ALGOLIA_ADMIN_API_KEY: string; SENDGRID_API_KEY: string; UNIVERSAL_LINK_SCHEME: string; - NFT_STORAGE_API_KEY: string; STELLAR_NETWORK: string; PINATA_JWT: string; AUDIBLE_SECRET: string; diff --git a/src/config/index.ts b/src/config/index.ts index 59094a2..d52f863 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -15,7 +15,6 @@ export const Config: IConfig = { ALGOLIA_ADMIN_API_KEY: process.env.ALGOLIA_ADMIN_API_KEY || '', SENDGRID_API_KEY: process.env.SENDGRID_API_KEY || '', UNIVERSAL_LINK_SCHEME: process.env.UNIVERSAL_LINK_SCHEME || '', - NFT_STORAGE_API_KEY: process.env.NFT_STORAGE_API_KEY || '', STELLAR_NETWORK: process.env.STELLAR_NETWORK || 'testnet', PINATA_JWT: process.env.PINATA_JWT || '', AUDIBLE_SECRET: diff --git a/src/graphql/call-contract.ts b/src/graphql/call-contract.ts new file mode 100644 index 0000000..c9c74a0 --- /dev/null +++ b/src/graphql/call-contract.ts @@ -0,0 +1,146 @@ +import { Keypair, Transaction, hash, scValToNative, xdr } from 'stellar-base'; +import { Client, Entry, networks } from 'contract-client'; +// import { getAuthenticatedUser } from '../auth/logic'; +// import { decrypt } from 'src/util/encryption'; +// import { Hyper } from '@stellar/js-xdr'; + +// const userKeys = Keypair.fromSecret(decrypt(user.seed)); + +// GBZP6P7QNKI342HNDUWXG5TE6DPIRIJBMERMZY5VCVHKVI67TJAYSK2C +const userKeys = Keypair.fromSecret( + 'SC5FF7SJOUA3XVCSPIXEG6L2ORFHQ6BTVJBJH345W2GRSACKYIUXUDUP' +); + +// GD7BAZM73BXQTMRHA2JVJPE5X4AATOMOIXGA76N22JNTNMVXRQW5DR4B +const sourceKeys = Keypair.fromSecret( + 'SB6NGNDLFKMRK4XW2W5OWFMJ2LIJ5SBXJU2X5TRSPXR2UNDOXHHZNKWY' +); + +const defaultOptions = { timeoutInSeconds: 60, fee: 100000000 }; + +function getClientForKeypair(keys: Keypair) { + return new Client({ + contractId: networks.testnet.contractId, + networkPassphrase: networks.testnet.networkPassphrase, + rpcUrl: 'https://soroban-testnet.stellar.org', + publicKey: keys.publicKey(), + signTransaction: async (tx: string, opts) => { + const txFromXDR = new Transaction(tx, opts.networkPassphrase); + + txFromXDR.sign(keys); + + return txFromXDR.toXDR(); + }, + signAuthEntry: async (entryXdr, opts) => { + return keys + .sign(hash(Buffer.from(entryXdr, 'base64'))) + .toString('base64'); + }, + }); +} + +const new_entry: Entry = { + ipfs_hash: 'abc', + total_invested: BigInt(0), + apr: BigInt(0), + equity_shares: new Map(), + escrow: BigInt(0), +}; + +const setEntry = async () => { + const contract = getClientForKeypair(sourceKeys); + const tx = await contract.set_entry({ entry: new_entry }, defaultOptions); + console.log(tx); + const res = await tx.signAndSend(); + console.log(res); + return res.getTransactionResponse; +}; + +const getEntry = async (ipfs_hash: string) => { + const contract = getClientForKeypair(sourceKeys); + const tx = await contract.get_entry( + { + ipfs_hash, + }, + defaultOptions + ); + console.log(tx); + console.log(tx.simulationData); + + return tx.result; +}; + +const distributePayouts = async () => { + const contract = getClientForKeypair(sourceKeys); + + // get mft issuer with our logic + let tx = await contract.distribute_payouts(); + return tx.result; +}; + +const invest = async (ipfs_hash: string, amount: number) => { + const contract = getClientForKeypair(sourceKeys); + + // get mft issuer with our logic + let tx = await contract.invest( + { + user: userKeys.publicKey(), + ipfs_hash, + amount: BigInt(amount), + }, + defaultOptions + ); + + const jsonFromRoot = tx.toJSON(); + + const userClient = getClientForKeypair(userKeys); + + const txUser = userClient.fromJSON['invest'](jsonFromRoot); + + await txUser.signAuthEntries(); + + const jsonFromUser = txUser.toJSON(); + + const txRoot = contract.fromJSON['invest'](jsonFromUser); + + const result = await txRoot.signAndSend(); + + // console.log('send res', result.sendTransactionResponseAll); + // console.log('get res', result.getTransactionResponseAll); + const getRes = result.getTransactionResponse as any; + + // console.log(getRes.resultMetaXdr.toXDR('base64')); + + console.log(getRes.resultXdr.toXDR('base64')); + + xdr.TransactionMeta.fromXDR(getRes.resultMetaXdr.toXDR('base64'), 'base64') + .v3() + .sorobanMeta() + ?.diagnosticEvents() + .forEach((event) => { + // console.log(event); + // console.log('event', event.event().body().v0().data().toXDR('base64')); + console.log(scValToNative(event.event().body().v0().data())); + }); + + return result.getTransactionResponse; +}; + +export const callContract = async (_: any, args: any, ctx: any) => { + // const user = await getAuthenticatedUser(ctx); + + const { fn, ipfs_hash } = args; + + switch (fn) { + case 'setEntry': + return setEntry(); + case 'getEntry': + return getEntry(ipfs_hash); + case 'invest': + return invest(ipfs_hash, 10000000); + case 'distribute': + return distributePayouts(); + } + + return {}; +}; diff --git a/src/graphql/resolvers.ts b/src/graphql/resolvers.ts index be29389..68e6e2b 100644 --- a/src/graphql/resolvers.ts +++ b/src/graphql/resolvers.ts @@ -1,3 +1,5 @@ +import GraphQLJSON from 'graphql-type-json'; + import { requestTokenResolver } from './request-token'; import { signInWithTokenResolver } from './sign-in-with-token'; import { userCreditsResolver } from './user-credits'; @@ -30,6 +32,7 @@ import { acceptBidResolver } from './accept-bid'; import { pinAssetUrlResolver } from './pin-asset-url'; import { decentralizeEntryResolver } from './decentralize-entry'; import { processEntryResolver } from './process-entry'; +import { callContract } from './call-contract'; const Query = { authenticatedUser: authenticatedUserResolver, @@ -43,6 +46,7 @@ const Query = { xlmPrice: XLMPriceResolver, getIssuer: getIssuerResolver, getAudibleToken: getAudibleTokenResolver, + callContract: callContract, }; const Mutation = { @@ -72,4 +76,5 @@ const Mutation = { export const resolvers = { Query, Mutation, + JSON: GraphQLJSON, }; diff --git a/src/graphql/schema.ts b/src/graphql/schema.ts index f3c918a..7d5327f 100644 --- a/src/graphql/schema.ts +++ b/src/graphql/schema.ts @@ -1,4 +1,6 @@ export const Schema = ` +scalar JSON + type Query { authenticatedUser: User! bids(assetCode: String!, assetIssuer: String!): [Offer!]! @@ -11,6 +13,7 @@ type Query { xlmPrice: String! getIssuer(cid: String!): String! getAudibleToken: Token! + callContract(fn: String!, ipfs_hash: String): JSON } type Mutation { diff --git a/src/graphql/server.ts b/src/graphql/server.ts index 89129b1..734a4a4 100644 --- a/src/graphql/server.ts +++ b/src/graphql/server.ts @@ -109,6 +109,12 @@ startGraphqlServer(); export default graphQLServer; +// graphql does not know how to serialize big ints +(BigInt.prototype as any).toJSON = function () { + const int = Number.parseInt(this.toString()); + return int ?? this.toString(); +}; + if (Config.ENV === 'development') { graphQLServer.listen(4000); } diff --git a/tsconfig.json b/tsconfig.json index 293daca..d071c80 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,8 +4,8 @@ "sourceMap": true, "noUnusedLocals": true, "esModuleInterop": true, - "module": "commonjs", - "moduleResolution": "node", + "module": "Preserve", + "moduleResolution": "Bundler", "target": "ESNext", "jsx": "react", "experimentalDecorators": true, diff --git a/yarn.lock b/yarn.lock index 1149338..d4b896a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -137,12 +137,12 @@ __metadata: languageName: node linkType: hard -"@apollo/cache-control-types@npm:^1.0.2": - version: 1.0.2 - resolution: "@apollo/cache-control-types@npm:1.0.2" +"@apollo/cache-control-types@npm:^1.0.3": + version: 1.0.3 + resolution: "@apollo/cache-control-types@npm:1.0.3" peerDependencies: graphql: 14.x || 15.x || 16.x - checksum: 10c0/685b29a3f68d4690fd6e7fd277a5dc4b26f4b65843a67e66b9c012981db9b979e690169acd04eb5196770cebc0c0ac7f987aee25f0b73f9e527b47bf6455fcea + checksum: 10c0/b49a9e99c7d5af6dfe12b775eb6374c8a54894e17ffa882b3d85f4501ca19ee413bdcc1a787a4b44dcc2903ce2c28f19b69116f338f88670c4f6f2e10a0bc498 languageName: node linkType: hard @@ -169,33 +169,33 @@ __metadata: languageName: node linkType: hard -"@apollo/server-gateway-interface@npm:^1.0.7": - version: 1.0.7 - resolution: "@apollo/server-gateway-interface@npm:1.0.7" +"@apollo/server-gateway-interface@npm:^1.1.1": + version: 1.1.1 + resolution: "@apollo/server-gateway-interface@npm:1.1.1" dependencies: - "@apollo/usage-reporting-protobuf": "npm:^4.0.0" + "@apollo/usage-reporting-protobuf": "npm:^4.1.1" "@apollo/utils.fetcher": "npm:^2.0.0" - "@apollo/utils.keyvaluecache": "npm:^2.0.1" + "@apollo/utils.keyvaluecache": "npm:^2.1.0" "@apollo/utils.logger": "npm:^2.0.0" peerDependencies: graphql: 14.x || 15.x || 16.x - checksum: 10c0/61469e6bf1f37d3de0b09639b2eef2347620f82c0bbbb37239be552827ce35222e092d10200c0425b4b2b96038f9a6b5661d8379b7978394cb57bdc773d1b3eb + checksum: 10c0/2787b2954028f5aff55846df98b3967f38f40df4c5e4c9df0da56ac16d4323ba0aeabd76d4b134fedc9f6fe7d63e6fd9e9a133eb5d209408eac34c0e25cbe7dd languageName: node linkType: hard -"@apollo/server@npm:^4.2.0": - version: 4.2.1 - resolution: "@apollo/server@npm:4.2.1" +"@apollo/server@npm:^4.10.4": + version: 4.10.4 + resolution: "@apollo/server@npm:4.10.4" dependencies: - "@apollo/cache-control-types": "npm:^1.0.2" - "@apollo/server-gateway-interface": "npm:^1.0.7" - "@apollo/usage-reporting-protobuf": "npm:^4.0.0" + "@apollo/cache-control-types": "npm:^1.0.3" + "@apollo/server-gateway-interface": "npm:^1.1.1" + "@apollo/usage-reporting-protobuf": "npm:^4.1.1" "@apollo/utils.createhash": "npm:^2.0.0" "@apollo/utils.fetcher": "npm:^2.0.0" "@apollo/utils.isnodelike": "npm:^2.0.0" - "@apollo/utils.keyvaluecache": "npm:^2.0.1" + "@apollo/utils.keyvaluecache": "npm:^2.1.0" "@apollo/utils.logger": "npm:^2.0.0" - "@apollo/utils.usagereporting": "npm:^2.0.0" + "@apollo/utils.usagereporting": "npm:^2.1.0" "@apollo/utils.withrequired": "npm:^2.0.0" "@graphql-tools/schema": "npm:^9.0.0" "@josephg/resolvable": "npm:^1.0.0" @@ -203,28 +203,27 @@ __metadata: "@types/express-serve-static-core": "npm:^4.17.30" "@types/node-fetch": "npm:^2.6.1" async-retry: "npm:^1.2.1" - body-parser: "npm:^1.20.0" cors: "npm:^2.8.5" express: "npm:^4.17.1" loglevel: "npm:^1.6.8" lru-cache: "npm:^7.10.1" negotiator: "npm:^0.6.3" - node-abort-controller: "npm:^3.0.1" + node-abort-controller: "npm:^3.1.1" node-fetch: "npm:^2.6.7" uuid: "npm:^9.0.0" whatwg-mimetype: "npm:^3.0.0" peerDependencies: graphql: ^16.6.0 - checksum: 10c0/55854d9054396baa157446cc21e940dc16413a1c7b0b742f2318813e1921f36bcc92ecf5bb166a5c07b6f6e96e5c2fa69ee12b0522db52953e2352956d3efbc5 + checksum: 10c0/e807ea6755e86cb86809c988542cf05ffafcffb752da2ccd1fe75912ca0beeecc33c36749c4ea498faa0fe6b5297a85da454b5b55f7cf76cf1b08cbd0b3effe9 languageName: node linkType: hard -"@apollo/usage-reporting-protobuf@npm:^4.0.0": - version: 4.0.2 - resolution: "@apollo/usage-reporting-protobuf@npm:4.0.2" +"@apollo/usage-reporting-protobuf@npm:^4.1.0, @apollo/usage-reporting-protobuf@npm:^4.1.1": + version: 4.1.1 + resolution: "@apollo/usage-reporting-protobuf@npm:4.1.1" dependencies: "@apollo/protobufjs": "npm:1.2.7" - checksum: 10c0/43425843a465ebde6d18744c80f50f9c2566126c418be1530fa9b987ed5cd19552511bff6f6da5293863e6aaaaa7d6857845d37f2691ae4920519dc271b53ec0 + checksum: 10c0/45f0167a87d4ae8a12124831ebb29905122d28afdbfa23a4f25f4570189d5ddaa6f2829ef97923f5909b9753e39dbd28f810ca2a93ad9fcd60b2baf5669f5223 languageName: node linkType: hard @@ -238,12 +237,12 @@ __metadata: languageName: node linkType: hard -"@apollo/utils.dropunuseddefinitions@npm:^2.0.0": - version: 2.0.0 - resolution: "@apollo/utils.dropunuseddefinitions@npm:2.0.0" +"@apollo/utils.dropunuseddefinitions@npm:^2.0.1": + version: 2.0.1 + resolution: "@apollo/utils.dropunuseddefinitions@npm:2.0.1" peerDependencies: graphql: 14.x || 15.x || 16.x - checksum: 10c0/856617663b6ab70c83c0cde6a3f5f24fb907a6179ff0858b42fa81fab054a57e802b14756e73f8f867f79327f720b2e515c95cf4316dfd6a2aed1e77fde356a5 + checksum: 10c0/4f646ac18219c16b77ffacf25cd18be4f0dfe7b4bd1fa4d57de7e0105c6f2daa71e30a9ba3266a322d4adb6fbbb2494b053748f3fbe7ed035683cf490b6abf38 languageName: node linkType: hard @@ -261,13 +260,13 @@ __metadata: languageName: node linkType: hard -"@apollo/utils.keyvaluecache@npm:^2.0.1": - version: 2.0.1 - resolution: "@apollo/utils.keyvaluecache@npm:2.0.1" +"@apollo/utils.keyvaluecache@npm:^2.1.0": + version: 2.1.1 + resolution: "@apollo/utils.keyvaluecache@npm:2.1.1" dependencies: - "@apollo/utils.logger": "npm:^2.0.0" + "@apollo/utils.logger": "npm:^2.0.1" lru-cache: "npm:^7.14.1" - checksum: 10c0/94002400aea95825b9af76ef676c05a05f33969f5b5e8a8e1623818401189d8aaa0356a27382e04263c4b0201ac41f9d196b0bc73cd23d7805d99ad277a46d90 + checksum: 10c0/393a66ccae32d0f0d346f796b9196c983abd9300e340ecdefa7edb5acd577693ef31ab72de73ef0acee689856a80f977938aab57d3eb9d8cbd3ce494cc4c0233 languageName: node linkType: hard @@ -278,57 +277,64 @@ __metadata: languageName: node linkType: hard -"@apollo/utils.printwithreducedwhitespace@npm:^2.0.0": - version: 2.0.0 - resolution: "@apollo/utils.printwithreducedwhitespace@npm:2.0.0" +"@apollo/utils.logger@npm:^2.0.1": + version: 2.0.1 + resolution: "@apollo/utils.logger@npm:2.0.1" + checksum: 10c0/7fcf72fdce95540907647ed99b878e2b84f82b963ab00e3bcfea082597d51a5b825411659e378c1497485f858e4e0bb7eb55369c502d96a0b87375d5036a92ba + languageName: node + linkType: hard + +"@apollo/utils.printwithreducedwhitespace@npm:^2.0.1": + version: 2.0.1 + resolution: "@apollo/utils.printwithreducedwhitespace@npm:2.0.1" peerDependencies: graphql: 14.x || 15.x || 16.x - checksum: 10c0/36fecead7b4ad0de770523d678a83f461a7af16d1356f7af2975df29157ce290b66666019fac785ccecee3d804ab20ed7817f771036a98edb5d6b9410950293a + checksum: 10c0/e4af07f8608bff93970574f891c98cb34c960faa3036d467180bb8964684c5d89357311269f78113e1871fc670a2be7672096f6de06180eb170a3219571a7881 languageName: node linkType: hard -"@apollo/utils.removealiases@npm:2.0.0": - version: 2.0.0 - resolution: "@apollo/utils.removealiases@npm:2.0.0" +"@apollo/utils.removealiases@npm:2.0.1": + version: 2.0.1 + resolution: "@apollo/utils.removealiases@npm:2.0.1" peerDependencies: graphql: 14.x || 15.x || 16.x - checksum: 10c0/2028d9303336d621f65fb19d7bcb4ee88fd77aad919ba71270f28303f28a0f06b6e6d828cd426db9074bf5dafe70bed907c22d9a5a5e78a6a550f5bde790468d + checksum: 10c0/8783fc0cfc04a3127d6537bef950c500c2ddf50206847e691b630dde9e7f3a402ed540800e19e69405e7421bdcc05fba84ce45cba9a824e550b405900efffcae languageName: node linkType: hard -"@apollo/utils.sortast@npm:^2.0.0": - version: 2.0.0 - resolution: "@apollo/utils.sortast@npm:2.0.0" +"@apollo/utils.sortast@npm:^2.0.1": + version: 2.0.1 + resolution: "@apollo/utils.sortast@npm:2.0.1" dependencies: lodash.sortby: "npm:^4.7.0" peerDependencies: graphql: 14.x || 15.x || 16.x - checksum: 10c0/b663944d4415648674bab47b3a4334811ddf61fcd591f77ac3ec87fbe1bc1e96b11bb13edb810fbbfa58d88807dc19649acd8bbd786049f394901cca417d8a09 + checksum: 10c0/5b8ccabfa4e86c31ab5108f72bcea8968fdc63f1a9306707365ddf77f7d8bd406dea494b269e4dee210c97a681ee031c60f9a34368dcee4692ec462d076a0bd9 languageName: node linkType: hard -"@apollo/utils.stripsensitiveliterals@npm:^2.0.0": - version: 2.0.0 - resolution: "@apollo/utils.stripsensitiveliterals@npm:2.0.0" +"@apollo/utils.stripsensitiveliterals@npm:^2.0.1": + version: 2.0.1 + resolution: "@apollo/utils.stripsensitiveliterals@npm:2.0.1" peerDependencies: graphql: 14.x || 15.x || 16.x - checksum: 10c0/f9ff3971841377ce2ee98be3ba24f68aaac30d9f8de1193ab2cc70f4b0e9cbd0fbde5e5a1f20bf1da4747f8b086869131a36206aaaa2a8bd87aee660b30c50c2 + checksum: 10c0/eb6b22e5a140be574e526da044a48ac0f8949b6f87dccb0c4224c02a5a3df4db82873ab128177476765f1091edde4f3dcae5cb73077827b2cb91489c1c7a8130 languageName: node linkType: hard -"@apollo/utils.usagereporting@npm:^2.0.0": - version: 2.0.0 - resolution: "@apollo/utils.usagereporting@npm:2.0.0" - dependencies: - "@apollo/usage-reporting-protobuf": "npm:^4.0.0" - "@apollo/utils.dropunuseddefinitions": "npm:^2.0.0" - "@apollo/utils.printwithreducedwhitespace": "npm:^2.0.0" - "@apollo/utils.removealiases": "npm:2.0.0" - "@apollo/utils.sortast": "npm:^2.0.0" - "@apollo/utils.stripsensitiveliterals": "npm:^2.0.0" +"@apollo/utils.usagereporting@npm:^2.1.0": + version: 2.1.0 + resolution: "@apollo/utils.usagereporting@npm:2.1.0" + dependencies: + "@apollo/usage-reporting-protobuf": "npm:^4.1.0" + "@apollo/utils.dropunuseddefinitions": "npm:^2.0.1" + "@apollo/utils.printwithreducedwhitespace": "npm:^2.0.1" + "@apollo/utils.removealiases": "npm:2.0.1" + "@apollo/utils.sortast": "npm:^2.0.1" + "@apollo/utils.stripsensitiveliterals": "npm:^2.0.1" peerDependencies: graphql: 14.x || 15.x || 16.x - checksum: 10c0/e68fdb8cf6807f7b71d2b738a38cb09dd9bd0332d747da818957653b4771c07975f6628a324c21d7f2303268d895b5697832c96a67a23e9fe299845492a06084 + checksum: 10c0/5c2b06a14c5094d0ee8eab7ff78449da1efff3bb4c82ef311b2bb90190437c6c59f2783702a428775f394f12455a53a9723e625e53e18e47b423df8cb9eb26d8 languageName: node linkType: hard @@ -864,6 +870,46 @@ __metadata: languageName: node linkType: hard +"@stellar/js-xdr@npm:^3.1.1": + version: 3.1.1 + resolution: "@stellar/js-xdr@npm:3.1.1" + checksum: 10c0/ba3f8327ea2eac6fc62ef2f87b90b13038e59cc397d837bc722484f682ae2d2aae7626ed91d16d75c20388af29cc7248919d5c64b40fdfb0cfb44cefde6e69e2 + languageName: node + linkType: hard + +"@stellar/stellar-base@npm:^12.0.0-rc.1": + version: 12.0.0 + resolution: "@stellar/stellar-base@npm:12.0.0" + dependencies: + "@stellar/js-xdr": "npm:^3.1.1" + base32.js: "npm:^0.1.0" + bignumber.js: "npm:^9.1.2" + buffer: "npm:^6.0.3" + sha.js: "npm:^2.3.6" + sodium-native: "npm:^4.1.1" + tweetnacl: "npm:^1.0.3" + dependenciesMeta: + sodium-native: + optional: true + checksum: 10c0/3b532c868a7a17b99692e53d941aed3a5c91778b370e91a978c2dfa98083e7880cfd485444a39e4e2086eee40ed42409a36a4058fa4351e7c0061d7f16c0e075 + languageName: node + linkType: hard + +"@stellar/stellar-sdk@npm:12.0.0-rc.3": + version: 12.0.0-rc.3 + resolution: "@stellar/stellar-sdk@npm:12.0.0-rc.3" + dependencies: + "@stellar/stellar-base": "npm:^12.0.0-rc.1" + axios: "npm:^1.6.8" + bignumber.js: "npm:^9.1.2" + eventsource: "npm:^2.0.2" + randombytes: "npm:^2.1.0" + toml: "npm:^3.0.0" + urijs: "npm:^1.19.1" + checksum: 10c0/2c5368c02062c71dea445fb70f15dfb81c2665f5765d8a8b9536d738bfe795e380d8e3d2668d96aac6da3add6371e8bcc541799ac008b098c0f48ec2b55de19b + languageName: node + linkType: hard + "@ts-morph/common@npm:~0.11.0": version: 0.11.1 resolution: "@ts-morph/common@npm:0.11.1" @@ -1247,9 +1293,11 @@ __metadata: version: 0.0.0-use.local resolution: "api@workspace:." dependencies: - "@apollo/server": "npm:^4.2.0" + "@apollo/server": "npm:^4.10.4" "@iarna/toml": "npm:^2.2.5" "@sendgrid/mail": "npm:^7.7.0" + "@stellar/js-xdr": "npm:^3.1.0" + "@stellar/stellar-sdk": "npm:12.0.0-rc.3" "@types/cors": "npm:^2.8.12" "@types/express-jwt": "npm:^6.0.4" "@types/graphql": "npm:^14.2.3" @@ -1257,7 +1305,7 @@ __metadata: "@vercel/node": "npm:2.4.0" algoliasearch: "npm:^4.14.2" async: "npm:^3.2.4" - axios: "npm:1.1.0" + axios: "npm:^1.7.2" axios-cache-adapter: "npm:^2.7.3" bcrypt: "npm:5.1.0" body-parser: "npm:^1.20.1" @@ -1268,16 +1316,17 @@ __metadata: express: "npm:^4.18.2" express-jwt: "npm:^7.7.7" graphql: "npm:^16.6.0" + graphql-type-json: "npm:^0.3.2" jsonwebtoken: "npm:^8.5.1" memory-cache: "npm:^0.2.0" prettier: "npm:2.8.0" sha.js: "npm:^2.4.11" sharp: "npm:^0.33.3" stellar-base: "npm:^11.0.0" - ts-node: "npm:^10.9.1" + ts-node: "npm:^10.9.2" tsconfig-paths: "npm:^4.1.0" tslint: "npm:^6.1.2" - typescript: "npm:^4.9.3" + typescript: "npm:^5.4.5" yup: "npm:^0.32.11" languageName: unknown linkType: soft @@ -1357,17 +1406,6 @@ __metadata: languageName: node linkType: hard -"axios@npm:1.1.0": - version: 1.1.0 - resolution: "axios@npm:1.1.0" - dependencies: - follow-redirects: "npm:^1.15.0" - form-data: "npm:^4.0.0" - proxy-from-env: "npm:^1.1.0" - checksum: 10c0/39cfcef4b85edea490eaca01b97a967915b6c4b01c42b04c67d72b6f1aab1ee1cd496a0d3fa4138d18bba9c5ff2988dd8a7687191226b0595fae62f518002077 - languageName: node - linkType: hard - "axios@npm:^0.26.0": version: 0.26.1 resolution: "axios@npm:0.26.1" @@ -1377,6 +1415,17 @@ __metadata: languageName: node linkType: hard +"axios@npm:^1.6.8, axios@npm:^1.7.2": + version: 1.7.2 + resolution: "axios@npm:1.7.2" + dependencies: + follow-redirects: "npm:^1.15.6" + form-data: "npm:^4.0.0" + proxy-from-env: "npm:^1.1.0" + checksum: 10c0/cbd47ce380fe045313364e740bb03b936420b8b5558c7ea36a4563db1258c658f05e40feb5ddd41f6633fdd96d37ac2a76f884dad599c5b0224b4c451b3fa7ae + languageName: node + linkType: hard + "balanced-match@npm:^1.0.0": version: 1.0.2 resolution: "balanced-match@npm:1.0.2" @@ -1422,7 +1471,7 @@ __metadata: languageName: node linkType: hard -"body-parser@npm:1.20.1, body-parser@npm:^1.20.0, body-parser@npm:^1.20.1": +"body-parser@npm:1.20.1, body-parser@npm:^1.20.1": version: 1.20.1 resolution: "body-parser@npm:1.20.1" dependencies: @@ -2199,6 +2248,13 @@ __metadata: languageName: node linkType: hard +"eventsource@npm:^2.0.2": + version: 2.0.2 + resolution: "eventsource@npm:2.0.2" + checksum: 10c0/0b8c70b35e45dd20f22ff64b001be9d530e33b92ca8bdbac9e004d0be00d957ab02ef33c917315f59bf2f20b178c56af85c52029bc8e6cc2d61c31d87d943573 + languageName: node + linkType: hard + "exit-hook@npm:2.2.1": version: 2.2.1 resolution: "exit-hook@npm:2.2.1" @@ -2323,7 +2379,7 @@ __metadata: languageName: node linkType: hard -"follow-redirects@npm:^1.14.8, follow-redirects@npm:^1.15.0": +"follow-redirects@npm:^1.14.8": version: 1.15.2 resolution: "follow-redirects@npm:1.15.2" peerDependenciesMeta: @@ -2333,6 +2389,16 @@ __metadata: languageName: node linkType: hard +"follow-redirects@npm:^1.15.6": + version: 1.15.6 + resolution: "follow-redirects@npm:1.15.6" + peerDependenciesMeta: + debug: + optional: true + checksum: 10c0/9ff767f0d7be6aa6870c82ac79cf0368cd73e01bbc00e9eb1c2a16fbb198ec105e3c9b6628bb98e9f3ac66fe29a957b9645bcb9a490bb7aa0d35f908b6b85071 + languageName: node + linkType: hard + "foreground-child@npm:^3.1.0": version: 3.1.1 resolution: "foreground-child@npm:3.1.1" @@ -2484,6 +2550,15 @@ __metadata: languageName: node linkType: hard +"graphql-type-json@npm:^0.3.2": + version: 0.3.2 + resolution: "graphql-type-json@npm:0.3.2" + peerDependencies: + graphql: ">=0.8.0" + checksum: 10c0/1ee7efff7f451cf2db6844430f4b19f8915175af11c1eeca31c8972685194669199cc542060d15cc9e169bb4d5a3cd16a6cf99081b9d802d8470048022a2924a + languageName: node + linkType: hard + "graphql@npm:*, graphql@npm:^16.6.0": version: 16.6.0 resolution: "graphql@npm:16.6.0" @@ -3223,10 +3298,10 @@ __metadata: languageName: node linkType: hard -"node-abort-controller@npm:^3.0.1": - version: 3.0.1 - resolution: "node-abort-controller@npm:3.0.1" - checksum: 10c0/37f895533f7a18a2d83fa4853da1cc00fcae1e0a71553f9ffc94d3153f5fc886d6d4ef3a33bf60c38be161fab78c5b2275cbbf2359351fb12f5edad68d88d8ca +"node-abort-controller@npm:^3.1.1": + version: 3.1.1 + resolution: "node-abort-controller@npm:3.1.1" + checksum: 10c0/f7ad0e7a8e33809d4f3a0d1d65036a711c39e9d23e0319d80ebe076b9a3b4432b4d6b86a7fab65521de3f6872ffed36fc35d1327487c48eb88c517803403eda3 languageName: node linkType: hard @@ -3271,6 +3346,17 @@ __metadata: languageName: node linkType: hard +"node-gyp-build@npm:^4.8.0": + version: 4.8.1 + resolution: "node-gyp-build@npm:4.8.1" + bin: + node-gyp-build: bin.js + node-gyp-build-optional: optional.js + node-gyp-build-test: build-test.js + checksum: 10c0/e36ca3d2adf2b9cca316695d7687207c19ac6ed326d6d7c68d7112cebe0de4f82d6733dff139132539fcc01cf5761f6c9082a21864ab9172edf84282bc849ce7 + languageName: node + linkType: hard + "node-gyp@npm:latest": version: 10.1.0 resolution: "node-gyp@npm:10.1.0" @@ -3535,6 +3621,15 @@ __metadata: languageName: node linkType: hard +"randombytes@npm:^2.1.0": + version: 2.1.0 + resolution: "randombytes@npm:2.1.0" + dependencies: + safe-buffer: "npm:^5.1.0" + checksum: 10c0/50395efda7a8c94f5dffab564f9ff89736064d32addf0cc7e8bf5e4166f09f8ded7a0849ca6c2d2a59478f7d90f78f20d8048bca3cdf8be09d8e8a10790388f3 + languageName: node + linkType: hard + "range-parser@npm:~1.2.1": version: 1.2.1 resolution: "range-parser@npm:1.2.1" @@ -3653,7 +3748,7 @@ __metadata: languageName: node linkType: hard -"safe-buffer@npm:5.2.1, safe-buffer@npm:^5.0.1, safe-buffer@npm:~5.2.0": +"safe-buffer@npm:5.2.1, safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.0, safe-buffer@npm:~5.2.0": version: 5.2.1 resolution: "safe-buffer@npm:5.2.1" checksum: 10c0/6501914237c0a86e9675d4e51d89ca3c21ffd6a31642efeba25ad65720bce6921c9e7e974e5be91a786b25aa058b5303285d3c15dbabf983a919f5f630d349f3 @@ -3923,6 +4018,16 @@ __metadata: languageName: node linkType: hard +"sodium-native@npm:^4.1.1": + version: 4.1.1 + resolution: "sodium-native@npm:4.1.1" + dependencies: + node-gyp: "npm:latest" + node-gyp-build: "npm:^4.8.0" + checksum: 10c0/7687554fc224bcd350a3b695de792d21b0c374d116d82306f16b5ff674c58f5f397667a1c977dd7e14bde2de4657b8bcd0bdd7cf435eb55173380c825754793f + languageName: node + linkType: hard + "source-map-support@npm:^0.5.17": version: 0.5.21 resolution: "source-map-support@npm:0.5.21" @@ -4114,6 +4219,13 @@ __metadata: languageName: node linkType: hard +"toml@npm:^3.0.0": + version: 3.0.0 + resolution: "toml@npm:3.0.0" + checksum: 10c0/8d7ed3e700ca602e5419fca343e1c595eb7aa177745141f0761a5b20874b58ee5c878cd045c408da9d130cb2b611c639912210ba96ce2f78e443569aa8060c18 + languageName: node + linkType: hard + "toposort@npm:^2.0.2": version: 2.0.2 resolution: "toposort@npm:2.0.2" @@ -4158,9 +4270,9 @@ __metadata: languageName: node linkType: hard -"ts-node@npm:^10.9.1": - version: 10.9.1 - resolution: "ts-node@npm:10.9.1" +"ts-node@npm:^10.9.2": + version: 10.9.2 + resolution: "ts-node@npm:10.9.2" dependencies: "@cspotcode/source-map-support": "npm:^0.8.0" "@tsconfig/node10": "npm:^1.0.7" @@ -4192,7 +4304,7 @@ __metadata: ts-node-script: dist/bin-script.js ts-node-transpile-only: dist/bin-transpile.js ts-script: dist/bin-script-deprecated.js - checksum: 10c0/95187932fb83f3901e22546bd2feeac7d2feb4f412f42ac3a595f049a23e8dcf70516dffb51866391228ea2dbcfaea039e250fb2bb334d48a86ab2b6aea0ae2d + checksum: 10c0/5f29938489f96982a25ba650b64218e83a3357d76f7bede80195c65ab44ad279c8357264639b7abdd5d7e75fc269a83daa0e9c62fd8637a3def67254ecc9ddc2 languageName: node linkType: hard @@ -4291,23 +4403,23 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^4.9.3": - version: 4.9.3 - resolution: "typescript@npm:4.9.3" +"typescript@npm:^5.3.3": + version: 5.3.3 + resolution: "typescript@npm:5.3.3" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/bddcb0794f2b8aa52094b9de9d70848fdf46ccecac68403e1c407dc9f1a4e4e28979887acd648e1917b1144e5d8fbfb4c824309d8806d393b4194aa39c71fe5e + checksum: 10c0/e33cef99d82573624fc0f854a2980322714986bc35b9cb4d1ce736ed182aeab78e2cb32b385efa493b2a976ef52c53e20d6c6918312353a91850e2b76f1ea44f languageName: node linkType: hard -"typescript@npm:^5.3.3": - version: 5.3.3 - resolution: "typescript@npm:5.3.3" +"typescript@npm:^5.4.5": + version: 5.4.5 + resolution: "typescript@npm:5.4.5" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/e33cef99d82573624fc0f854a2980322714986bc35b9cb4d1ce736ed182aeab78e2cb32b385efa493b2a976ef52c53e20d6c6918312353a91850e2b76f1ea44f + checksum: 10c0/2954022ada340fd3d6a9e2b8e534f65d57c92d5f3989a263754a78aba549f7e6529acc1921913560a4b816c46dce7df4a4d29f9f11a3dc0d4213bb76d043251e languageName: node linkType: hard @@ -4321,23 +4433,23 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@npm%3A^4.9.3#optional!builtin": - version: 4.9.3 - resolution: "typescript@patch:typescript@npm%3A4.9.3#optional!builtin::version=4.9.3&hash=a66ed4" +"typescript@patch:typescript@npm%3A^5.3.3#optional!builtin": + version: 5.3.3 + resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/e5a7c3c6b75cf3eb2b6619fdc84f7ee434659413ace558da8b2c7270b21266be689ece5cf8e6bba529cdd3ea36d3c8ddac9c6d63e5f5c5224c1eac8785c92620 + checksum: 10c0/1d0a5f4ce496c42caa9a30e659c467c5686eae15d54b027ee7866744952547f1be1262f2d40de911618c242b510029d51d43ff605dba8fb740ec85ca2d3f9500 languageName: node linkType: hard -"typescript@patch:typescript@npm%3A^5.3.3#optional!builtin": - version: 5.3.3 - resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7" +"typescript@patch:typescript@npm%3A^5.4.5#optional!builtin": + version: 5.4.5 + resolution: "typescript@patch:typescript@npm%3A5.4.5#optional!builtin::version=5.4.5&hash=5adc0c" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/1d0a5f4ce496c42caa9a30e659c467c5686eae15d54b027ee7866744952547f1be1262f2d40de911618c242b510029d51d43ff605dba8fb740ec85ca2d3f9500 + checksum: 10c0/db2ad2a16ca829f50427eeb1da155e7a45e598eec7b086d8b4e8ba44e5a235f758e606d681c66992230d3fc3b8995865e5fd0b22a2c95486d0b3200f83072ec9 languageName: node linkType: hard @@ -4375,6 +4487,13 @@ __metadata: languageName: node linkType: hard +"urijs@npm:^1.19.1": + version: 1.19.11 + resolution: "urijs@npm:1.19.11" + checksum: 10c0/96e15eea5b41a99361d506e4d8fcc64dc43f334bd5fd34e08261467b6954b97a6b45929a8d6c79e2dc76aadfd6ca950e0f4bd7f3c0757a08978429634d07eda1 + languageName: node + linkType: hard + "util-deprecate@npm:^1.0.1": version: 1.0.2 resolution: "util-deprecate@npm:1.0.2"