Skip to content

Commit

Permalink
example: update examples and run during the build
Browse files Browse the repository at this point in the history
Run all of the examples to ensure they stay up-to-date and working.

Signed-off-by: Andrew Richardson <[email protected]>
  • Loading branch information
awrichar committed Dec 13, 2024
1 parent 6c9f5c7 commit 9438295
Show file tree
Hide file tree
Showing 14 changed files with 191 additions and 190 deletions.
12 changes: 6 additions & 6 deletions doc-site/docs/tutorials/bond-issuance.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ await paladin1.sendTransaction({
abi: bondTrackerPublicJson.abi,
bytecode: bondTrackerPublicJson.bytecode,
function: "",
from: bondIssuerUnqualified,
from: bondIssuer.lookup,
data: {
owner: issuerCustodianGroup.address,
issueDate_: issueDate,
Expand All @@ -108,7 +108,7 @@ events throughout the bond's lifetime.
await newBondTracker(issuerCustodianGroup, bondIssuer, {
name: "BOND",
symbol: "BOND",
custodian: bondCustodianAddress,
custodian: await bondCustodian.address(),
publicTracker: bondTrackerPublicAddress,
});
```
Expand Down Expand Up @@ -149,7 +149,7 @@ await paladin1.sendTransaction({
abi: atomFactoryJson.abi,
bytecode: atomFactoryJson.bytecode,
function: "",
from: bondIssuerUnqualified,
from: bondIssuer.lookup,
data: {},
});
```
Expand Down Expand Up @@ -189,7 +189,7 @@ await bondTracker.using(paladin2).beginDistribution(bondCustodian, {
const investorList = await bondTracker.investorList(bondIssuer);
await investorList
.using(paladin2)
.addInvestor(bondCustodian, { addr: investorAddress });
.addInvestor(bondCustodian, { addr: await investor.address() });
```

This allows the bond custodian to begin distributing the bond to potential investors. Each investor must be added
Expand Down Expand Up @@ -227,7 +227,7 @@ const bondSubscription = await newBondSubscription(
{
bondAddress_: notoBond.address,
units_: 100,
custodian_: bondCustodianAddress,
custodian_: await bondCustodian.address(),
atomFactory_: atomFactoryAddress,
}
);
Expand Down Expand Up @@ -336,7 +336,7 @@ await paladin2.sendTransaction({
type: TransactionType.PUBLIC,
abi: atomJson.abi,
function: "execute",
from: bondCustodianUnqualified,
from: bondCustodian.lookup,
to: atomAddress,
data: {},
});
Expand Down
23 changes: 13 additions & 10 deletions example/bond/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ configurations {
}

dependencies {
contractCompile project(path: ":solidity", configuration: "compiledContracts")
buildSDK project(path: ":sdk:typescript", configuration: "buildSDK")
contractCompile project(path: ':solidity', configuration: 'compiledContracts')
buildSDK project(path: ':sdk:typescript', configuration: 'buildSDK')
}

task install(type: Exec) {
executable 'npm'
args 'install'

inputs.files(configurations.buildSDK)
inputs.files("package.json")
outputs.files("package-lock.json")
outputs.dir("node_modules")
inputs.files('package.json')
outputs.files('package-lock.json')
outputs.dir('node_modules')
}

task copyABI(type: Exec, dependsOn: install) {
Expand All @@ -46,19 +46,22 @@ task copyABI(type: Exec, dependsOn: install) {
args 'abi'

inputs.files(configurations.contractCompile)
inputs.dir('scripts')
outputs.dir('src/abis')
}

task build(type: Exec, dependsOn: [install, copyABI]) {
dependsOn ':testinfra:startTestInfra'

executable 'npm'
args 'run'
args 'build'
args 'start'

inputs.dir("src")
outputs.dir("build")
inputs.dir('src')
outputs.dir('build')
}

task clean(type: Delete) {
delete "node_modules"
delete "build"
delete 'node_modules'
delete 'build'
}
10 changes: 5 additions & 5 deletions example/bond/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/bond/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"typescript": "^5.6.3"
},
"dependencies": {
"paladin-sdk": "file:../../sdk/typescript"
"@lfdecentralizedtrust-labs/paladin-sdk": "file:../../sdk/typescript"
}
}
11 changes: 6 additions & 5 deletions example/bond/src/helpers/bondsubscription.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import PaladinClient, {
PaladinVerifier,
PentePrivacyGroup,
PentePrivateContract,
} from "paladin-sdk";
} from "@lfdecentralizedtrust-labs/paladin-sdk";
import bondSubscription from "../abis/BondSubscription.json";

const bondSubscriptionConstructor = bondSubscription.abi.find(
Expand All @@ -27,7 +28,7 @@ export interface PrepareBondParams {

export const newBondSubscription = async (
pente: PentePrivacyGroup,
from: string,
from: PaladinVerifier,
params: BondSubscriptionConstructorParams
) => {
if (bondSubscriptionConstructor === undefined) {
Expand All @@ -54,15 +55,15 @@ export class BondSubscription extends PentePrivateContract<BondSubscriptionConst
return new BondSubscription(this.evm.using(paladin), this.address);
}

preparePayment(from: string, params: PreparePaymentParams) {
preparePayment(from: PaladinVerifier, params: PreparePaymentParams) {
return this.invoke(from, "preparePayment", params);
}

prepareBond(from: string, params: PrepareBondParams) {
prepareBond(from: PaladinVerifier, params: PrepareBondParams) {
return this.invoke(from, "prepareBond", params);
}

async distribute(from: string) {
async distribute(from: PaladinVerifier) {
return this.invoke(from, "distribute", {});
}
}
9 changes: 5 additions & 4 deletions example/bond/src/helpers/bondtracker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import PaladinClient, {
PaladinVerifier,
PentePrivacyGroup,
PentePrivateContract,
} from "paladin-sdk";
} from "@lfdecentralizedtrust-labs/paladin-sdk";
import bondTracker from "../abis/BondTracker.json";
import { InvestorList } from "./investorlist";

Expand All @@ -19,7 +20,7 @@ export interface BeginDistributionParams {

export const newBondTracker = async (
pente: PentePrivacyGroup,
from: string,
from: PaladinVerifier,
params: BondTrackerConstructorParams
) => {
const address = await pente.deploy(
Expand All @@ -43,11 +44,11 @@ export class BondTracker extends PentePrivateContract<BondTrackerConstructorPara
return new BondTracker(this.evm.using(paladin), this.address);
}

beginDistribution(from: string, params: BeginDistributionParams) {
beginDistribution(from: PaladinVerifier, params: BeginDistributionParams) {
return this.invoke(from, "beginDistribution", params);
}

async investorList(from: string) {
async investorList(from: PaladinVerifier) {
const result = await this.call(from, "investorList", []);
return new InvestorList(this.evm, result[0]);
}
Expand Down
5 changes: 3 additions & 2 deletions example/bond/src/helpers/investorlist.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import PaladinClient, {
PaladinVerifier,
PentePrivacyGroup,
PentePrivateContract,
} from "paladin-sdk";
} from "@lfdecentralizedtrust-labs/paladin-sdk";
import investorList from "../abis/InvestorList.json";

export interface AddInvestorParams {
Expand All @@ -20,7 +21,7 @@ export class InvestorList extends PentePrivateContract<{}> {
return new InvestorList(this.evm.using(paladin), this.address);
}

addInvestor(from: string, params: AddInvestorParams) {
addInvestor(from: PaladinVerifier, params: AddInvestorParams) {
return this.invoke(from, "addInvestor", params);
}
}
Loading

0 comments on commit 9438295

Please sign in to comment.