Skip to content

Commit

Permalink
Merge pull request #21 from 00labs/bump-version
Browse files Browse the repository at this point in the history
Bump all versions
  • Loading branch information
mliu authored Jul 18, 2024
2 parents 72181d2 + ad85441 commit bed6081
Show file tree
Hide file tree
Showing 76 changed files with 282 additions and 1,115 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"test:all": "yarn test:sdk",
"test:sdk": "yarn workspace @huma-finance/soroban-sdk test",
"prepare": "husky install",
"binding": "ts-node scripts/bindings.ts"
"example": "yarn workspace @huma-finance/soroban-examples startDrawdownPayback"
},
"devDependencies": {
"lerna": "^6.6.1"
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ associated with the given pool name on the current chain.</p></dd>
<dd><p>Approve allowance for sentinel if not enough allowance is approved.</p></dd>
<dt><a href="#drawdown">drawdown(poolName, network, wallet, drawdownAmount)</a> ⇒ <code>Promise.&lt;SentTransaction&gt;</code></dt>
<dd><p>Draws down from a pool.</p></dd>
<dt><a href="#makePayment">makePayment(poolName, network, wallet, paymentAmount, principalOnly)</a> ⇒ <code>Promise.&lt;AssembledTransaction&gt;</code></dt>
<dt><a href="#makePayment">makePayment(poolName, network, wallet, paymentAmount, principalOnly)</a> ⇒ <code>Promise.&lt;SentTransaction&gt;</code></dt>
<dd><p>Makes a payment.</p></dd>
<dt><a href="#approveSep41AllowanceIfInsufficient">approveSep41AllowanceIfInsufficient(network, wallet, tokenAddress, spenderAddress, allowanceAmount)</a> ⇒ <code>Promise.&lt;(SentTransaction.&lt;null&gt;|null)&gt;</code></dt>
<dd><p>Approves an Sep41 allowance for a spender address, if the current allowance is insufficient.
Expand Down Expand Up @@ -135,12 +135,12 @@ associated with the given pool name on the current chain.</p>

<a name="makePayment"></a>

## makePayment(poolName, network, wallet, paymentAmount, principalOnly) ⇒ <code>Promise.&lt;AssembledTransaction&gt;</code>
## makePayment(poolName, network, wallet, paymentAmount, principalOnly) ⇒ <code>Promise.&lt;SentTransaction&gt;</code>
<p>Makes a payment.</p>

**Kind**: global function
**Returns**: <code>Promise.&lt;AssembledTransaction&gt;</code> - <ul>
<li>A Promise of the AssembledTransaction.</li>
**Returns**: <code>Promise.&lt;SentTransaction&gt;</code> - <ul>
<li>A Promise of the SentTransaction.</li>
</ul>

| Param | Type | Description |
Expand Down
9 changes: 5 additions & 4 deletions packages/sdk/src/helpers/CreditContractHelper.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {
Client as PoolCreditClient,
CreditRecord,
SentTransaction,
} from '@huma-finance/soroban-pool-credit'

import { SentTransaction } from '@stellar/stellar-sdk/lib/contract'
import { StellarWallet } from '../services/StellarWallet'
import {
getCreditStorageClient,
Expand Down Expand Up @@ -129,7 +128,9 @@ export async function getAvailableCreditForPool(
throw new Error('Could not find credit config or credit record')
}

return creditConfig.credit_limit - creditRecord.unbilled_principal
return (
BigInt(creditConfig.credit_limit) - BigInt(creditRecord.unbilled_principal)
)
}

/**
Expand Down Expand Up @@ -255,7 +256,7 @@ export async function drawdown(
* @param {StellarWallet} wallet - The stellar wallet.
* @param {bigint} paymentAmount - The amount to payback.
* @param {boolean} principalOnly - Whether this payment should ONLY apply to the principal
* @returns {Promise<AssembledTransaction>} - A Promise of the AssembledTransaction.
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
*/
export async function makePayment(
poolName: POOL_NAME,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/helpers/Sep41ContractHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SentTransaction } from '@huma-finance/soroban-pool-credit'
import { SentTransaction } from '@stellar/stellar-sdk/lib/contract'

import { StellarWallet } from '../services'
import {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/utils/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ export const getTrancheVaultClient = (
tranche: 'senior' | 'junior',
) => {
const poolMetadata = findPoolMetadata(network, poolName)
if (!poolMetadata) {
if (!poolMetadata || !poolMetadata.contracts[`${tranche}Tranche`]) {
return undefined
}

return new TrancheVaultClient({
contractId: poolMetadata.contracts[`${tranche}Tranche`],
contractId: poolMetadata.contracts[`${tranche}Tranche`]!,
...getCommonProps(network, wallet),
})
}
Expand Down
20 changes: 9 additions & 11 deletions packages/sdk/src/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export type PoolMetadata = {
poolCredit: string
creditManager: string
creditStorage: string
seniorTranche: string
juniorTranche: string
seniorTranche?: string
}
}

Expand All @@ -64,22 +64,20 @@ export const NetworkMetadatas: NetworkMetadata[] = [
poolType: POOL_TYPE.Creditline,
contracts: {
humaConfig:
'CDEH36NMZK6AV5I675A2BSRIWLJGBVXWN5HHABKJKHNIGKSKJQVXPXFB',
'CBXUR3AZ55267TY5ZN3VDWMCLTYIXWRM3A6CY35WUI3IXERALALZFL5X',
poolStorage:
'CBHY4NM3DVEBX3QTL3X5XEOAKHDMP44HDP7SBDTCOAMFU7LFIBMFEV4N',
pool: 'CAI6UQAXZ6ICE5QQ4WFEEDQLZORGMYBCL2RB2NVY6AGMH4XT6PCH7IPX',
'CDJ6XX2WBWREDZDGAOGLULXHSS4KNIPQHVPATG6KVDZ5J5HTTTLLDC43',
pool: 'CCEE4AEQXENDNCBBE6NJA43UOFXDHVCAIARAR2NAKPETKJ6HTS6QAOFW',
poolManager:
'CCTCNYWWKPVFNPJDQUMJM6GFBU6IJSZH6CHPM5COJTBMWO64A4XVCXNV',
'CAPUJ7SFTTAM6I2O6MR2SKMFWWK7ZZCDIFWYPKQVDEPVGEHHSQXVMI77',
poolCredit:
'CCYWDOW34SPB3FCR6A633B5GS5DPRRQKTTCT4DU7YYFDRT7XBOA2HYYY',
'CCANGNNOXXTCDJ4DTN6RQZ6LL7BPDKOFJFD62G4AQ7OG362PCVG4OK3U',
creditManager:
'CDHYIC3ISV3F3RL7FROC3SI2GW65ZOJHMA2AMZJYLIRLWSDELFF3CR23',
'CDJ4B3MPTOIYQ3BUHAFSNNK3OIOMTB4H2L4LZLHTUWP2B6KX6KRZNCLW',
creditStorage:
'CBZHE4LD4FYGELCFDVRNBLNO4743X4UJDIDC7CGYS3MLJ3CIHC4SGLHC',
'CCWDV53HATIFKR3WL2G64BA7AFA4HIAJWE3ADHJY54XQTM3EYCIN2SHS',
juniorTranche:
'CAJZ4V2N5TOJ6GVOJOKTJSP3QYDNVC6O6TDO2V64GULQGZNRRFM5AS7V',
seniorTranche:
'CBQV4USFV4MBZTKK6W6SM576GVBZGZZHEHT7Y2OVIKNYG45L57LDL6SA',
'CC356H4PYZWNZ4G5P2LZUSD65PZK5OHAFDRM37QE27TZ5BOYRYQB7S7M',
},
},
],
Expand Down
4 changes: 4 additions & 0 deletions packages/sdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"paths": {
"@": ["./"],
"*": ["src/*", "node_modules/*"],
"@huma-finance/soroban-credit-manager": ["../tb-creditManager"],
"@huma-finance/soroban-credit-storage": ["../tb-creditStorage"],
"@huma-finance/soroban-huma-config": ["../tb-humaConfig"],
"@huma-finance/soroban-pool": ["../tb-pool"],
Expand All @@ -38,6 +39,9 @@
"skipLibCheck": true
},
"references": [
{
"path": "../tb-creditManager"
},
{
"path": "../tb-creditStorage"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/tb-creditManager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This library was automatically generated by Soroban CLI using a command similar
soroban contract bindings ts \
--rpc-url https://soroban-testnet.stellar.org:443 \
--network-passphrase "Test SDF Network ; September 2015" \
--contract-id CASGH7RO7Q4H3JOMACIFKIVZDIL7AFHYELXB5JQ6VWTMQ7IMO6GEBRQ5 \
--contract-id CDHYIC3ISV3F3RL7FROC3SI2GW65ZOJHMA2AMZJYLIRLWSDELFF3CR23 \
--output-dir ./path/to/tb-creditManager
```

Expand All @@ -30,7 +30,7 @@ However, we've actually encountered [frustration](https://github.com/stellar/sor

```json
"scripts": {
"postinstall": "soroban contract bindings ts --rpc-url https://soroban-testnet.stellar.org:443 --network-passphrase \"Test SDF Network ; September 2015\" --id CASGH7RO7Q4H3JOMACIFKIVZDIL7AFHYELXB5JQ6VWTMQ7IMO6GEBRQ5 --name tb-creditManager"
"postinstall": "soroban contract bindings ts --rpc-url https://soroban-testnet.stellar.org:443 --network-passphrase \"Test SDF Network ; September 2015\" --id CDHYIC3ISV3F3RL7FROC3SI2GW65ZOJHMA2AMZJYLIRLWSDELFF3CR23 --name tb-creditManager"
}
```

Expand Down
15 changes: 4 additions & 11 deletions packages/tb-creditManager/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
{
"version": "0.0.14",
"name": "@huma-finance/soroban-credit-manager",
"exports": "./dist/index.js",
"typings": "dist/index.d.ts",
"dependencies": {
"@stellar/freighter-api": "2.0.0",
"@stellar/stellar-sdk": "11.3.0",
"@stellar/stellar-sdk": "^12.1.0",
"buffer": "6.0.3"
},
"types": "./dist/types/index.d.ts",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"scripts": {
"build": "node ./scripts/build.mjs"
"build": "tsc"
},
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
},
"typings": "dist/types/index.d.ts",
"devDependencies": {
"typescript": "5.3.3"
},
Expand Down
37 changes: 0 additions & 37 deletions packages/tb-creditManager/scripts/build.mjs

This file was deleted.

7 changes: 0 additions & 7 deletions packages/tb-creditManager/scripts/tsconfig.cjs.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/tb-creditManager/scripts/tsconfig.esm.json

This file was deleted.

8 changes: 0 additions & 8 deletions packages/tb-creditManager/scripts/tsconfig.types.json

This file was deleted.

26 changes: 17 additions & 9 deletions packages/tb-creditManager/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { ContractSpec, Address } from "@stellar/stellar-sdk";
import { Buffer } from "buffer";
import { Address } from "@stellar/stellar-sdk";
import {
AssembledTransaction,
ContractClient,
ContractClientOptions,
} from "@stellar/stellar-sdk/lib/contract_client/index.js";
Client as ContractClient,
ClientOptions as ContractClientOptions,
Result,
Spec as ContractSpec,
} from "@stellar/stellar-sdk/contract";
import type {
u32,
i32,
Expand All @@ -17,11 +19,10 @@ import type {
Option,
Typepoint,
Duration,
} from "@stellar/stellar-sdk/lib/contract_client";
import { Result } from "@stellar/stellar-sdk/lib/rust_types/index.js";
} from "@stellar/stellar-sdk/contract";
export * from "@stellar/stellar-sdk";
export * from "@stellar/stellar-sdk/lib/contract_client/index.js";
export * from "@stellar/stellar-sdk/lib/rust_types/index.js";
export * as contract from "@stellar/stellar-sdk/contract";
export * as rpc from "@stellar/stellar-sdk/rpc";

if (typeof window !== "undefined") {
//@ts-ignore Buffer exists
Expand All @@ -31,7 +32,7 @@ if (typeof window !== "undefined") {
export const networks = {
testnet: {
networkPassphrase: "Test SDF Network ; September 2015",
contractId: "CASGH7RO7Q4H3JOMACIFKIVZDIL7AFHYELXB5JQ6VWTMQ7IMO6GEBRQ5",
contractId: "CDHYIC3ISV3F3RL7FROC3SI2GW65ZOJHMA2AMZJYLIRLWSDELFF3CR23",
},
} as const;

Expand Down Expand Up @@ -182,6 +183,13 @@ export const Errors = {
713: { message: "" },
714: { message: "" },
715: { message: "" },
101: { message: "" },
1: { message: "" },
2: { message: "" },
3: { message: "" },
4: { message: "" },
5: { message: "" },
221: { message: "" },
};
export type PayPeriodDuration =
| { tag: "Monthly"; values: void }
Expand Down
4 changes: 2 additions & 2 deletions packages/tb-creditManager/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"compilerOptions": {
"composite": true,
"target": "ESNext",
"module": "ESNext",
"module": "NodeNext",
"rootDir": "./src",
"outDir": "dist",
"moduleResolution": "node",
"moduleResolution": "NodeNext",
"declaration": true,
"strictNullChecks": true,
"skipLibCheck": true
Expand Down
4 changes: 2 additions & 2 deletions packages/tb-creditStorage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This library was automatically generated by Soroban CLI using a command similar
soroban contract bindings ts \
--rpc-url https://soroban-testnet.stellar.org:443 \
--network-passphrase "Test SDF Network ; September 2015" \
--contract-id CAWXNUPJVXSPZ4WSWURNYYPECL3GDPLLP7LSSBMRXMDGWZ4ZXNIHMITS \
--contract-id CBZHE4LD4FYGELCFDVRNBLNO4743X4UJDIDC7CGYS3MLJ3CIHC4SGLHC \
--output-dir ./path/to/tb-creditStorage
```

Expand All @@ -30,7 +30,7 @@ However, we've actually encountered [frustration](https://github.com/stellar/sor

```json
"scripts": {
"postinstall": "soroban contract bindings ts --rpc-url https://soroban-testnet.stellar.org:443 --network-passphrase \"Test SDF Network ; September 2015\" --id CAWXNUPJVXSPZ4WSWURNYYPECL3GDPLLP7LSSBMRXMDGWZ4ZXNIHMITS --name tb-creditStorage"
"postinstall": "soroban contract bindings ts --rpc-url https://soroban-testnet.stellar.org:443 --network-passphrase \"Test SDF Network ; September 2015\" --id CBZHE4LD4FYGELCFDVRNBLNO4743X4UJDIDC7CGYS3MLJ3CIHC4SGLHC --name tb-creditStorage"
}
```

Expand Down
19 changes: 6 additions & 13 deletions packages/tb-creditStorage/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
{
"version": "0.0.14",
"name": "@huma-finance/soroban-credit-storage",
"dependencies": {
"@stellar/freighter-api": "2.0.0",
"@stellar/stellar-sdk": "11.3.0",
"buffer": "6.0.3"
},
"types": "./dist/types/index.d.ts",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"exports": "./dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"build": "node ./scripts/build.mjs"
"build": "tsc"
},
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
"dependencies": {
"@stellar/stellar-sdk": "12.1.0",
"buffer": "6.0.3"
},
"typings": "dist/types/index.d.ts",
"devDependencies": {
"typescript": "5.3.3"
},
Expand Down
Loading

0 comments on commit bed6081

Please sign in to comment.