Skip to content

Commit

Permalink
docs: improve typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
arobsn committed Dec 17, 2024
1 parent e1c2738 commit 57d9781
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions docs/dapp-connector/wallet-interaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The code above returns an array of all UTxOs owned by the selected wallet.
### UTxO Type Definitions

```ts
interface Box = {
interface Box {
boxId: string;
transactionId: string;
index: number;
Expand All @@ -74,8 +74,8 @@ interface Box = {
value: string;
assets: { tokenId: string; amount: string }[];
additionalRegisters: Partial<Record<"R4" | "R5" | "R6" | "R7" | "R8" | "R9", string>>;
confirmed?: boolean; // false if the UTxO is still unconfirmed
};
confirmed?: boolean; // true if included in the blockchain
}
```

### Filter UTxOs
Expand Down Expand Up @@ -142,18 +142,41 @@ As the focus of this guide is specifically on the **dApp Connector** protocol, w
The `sign_tx()` method requires the transaction object to be structured in a slightly different way than what's required by the node: the `inputs` and `dataInputs` properties must be full [Box objects](#utxo-type-definitions), instead of an object containing the `BoxID`.

```ts
interface UnsignedTransaction = {
inputs: Box[]; // see "UTxO Type Definitions" for Box type details.
dataInputs: Box[];
outputs: {
interface UnsignedTransaction {
inputs: Array<{
boxId: string;
transactionId: string;
index: number;
ergoTree: string;
creationHeight: number;
value: string;
assets: { tokenId: string; amount: string }[];
additionalRegisters: Partial<Record<"R4" | "R5" | "R6" | "R7" | "R8" | "R9", string>>;
};
};
assets: TokenAmount[];
additionalRegisters: NonMandatoryRegisters;
extension: { values?: Record<string, string> };
}>;

dataInputs: Array<{
boxId: string;
transactionId: string;
index: number;
ergoTree: string;
creationHeight: number;
value: string;
assets: TokenAmount[];
additionalRegisters: NonMandatoryRegisters;
}>;

outputs: Array<{
ergoTree: string;
creationHeight: number;
value: string;
assets: TokenAmount[];
additionalRegisters: NonMandatoryRegisters;
}>;
}

type TokenAmount = Array<{ tokenId: string; amount: string }>;
type NonMandatoryRegisters = Partial<Record<"R4" | "R5" | "R6" | "R7" | "R8" | "R9", string>>;
```

### Submit a Transaction
Expand Down

0 comments on commit 57d9781

Please sign in to comment.