Skip to content

Commit

Permalink
Merge branch 'main' into GIX-1909_LM_update-sns-js-candid
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuntaner authored Sep 27, 2023
2 parents 2c9069a + d9f3f5a commit 03ed6b2
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 48 deletions.
5 changes: 5 additions & 0 deletions packages/ledger/src/converters/ledger.converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import type {
TransferParams,
} from "../types/ledger.params";

// WARNING: When using the ICRC-1 interface of the ICP ledger, there is no
// relationship between the memo and the icrc1Memo of a transaction. The ICRC-1
// interface simply cannot set the memo field and the non-ICRC-1 interface
// cannot set the icrc1Memo field, even though the icrc1Memo field is called
// just "memo" in canister method params.
export const toTransferArg = ({
from_subaccount,
fee,
Expand Down
5 changes: 5 additions & 0 deletions packages/ledger/src/types/ledger.params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import type { IcrcAccount } from "./ledger.responses";
*/
export type BalanceParams = IcrcAccount & QueryParams;

// WARNING: When using the ICRC-1 interface of the ICP ledger, there is no
// relationship between the memo and the icrc1Memo of a transaction. The ICRC-1
// interface simply cannot set the memo field and the non-ICRC-1 interface
// cannot set the icrc1Memo field, even though the icrc1Memo field is called
// just "memo" in canister method params.
/**
* Params to make a transfer in an ICRC-1 ledger
*
Expand Down
50 changes: 25 additions & 25 deletions packages/nns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ Returns the index of the block containing the tx if it was successful.
| --------------- | ---------------------------------------------------- |
| `icrc1Transfer` | `(request: Icrc1TransferRequest) => Promise<bigint>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/ledger.canister.ts#L137)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/ledger.canister.ts#L142)

### :factory: GovernanceCanister

Expand Down Expand Up @@ -453,7 +453,7 @@ Increases dissolve delay of a neuron
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `increaseDissolveDelay` | `({ neuronId, additionalDissolveDelaySeconds, }: { neuronId: bigint; additionalDissolveDelaySeconds: number; }) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L371)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L373)

##### :gear: setDissolveDelay

Expand All @@ -464,7 +464,7 @@ The new date is now + dissolveDelaySeconds.
| ------------------ | ------------------------------------------------------------------------------------------------------------- |
| `setDissolveDelay` | `({ neuronId, dissolveDelaySeconds, }: { neuronId: bigint; dissolveDelaySeconds: number; }) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L403)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L405)

##### :gear: startDissolving

Expand All @@ -474,7 +474,7 @@ Start dissolving process of a neuron
| ----------------- | ------------------------------------- |
| `startDissolving` | `(neuronId: bigint) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L426)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L428)

##### :gear: stopDissolving

Expand All @@ -484,7 +484,7 @@ Stop dissolving process of a neuron
| ---------------- | ------------------------------------- |
| `stopDissolving` | `(neuronId: bigint) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L443)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L445)

##### :gear: joinCommunityFund

Expand All @@ -494,7 +494,7 @@ Neuron joins the community fund
| ------------------- | ------------------------------------- |
| `joinCommunityFund` | `(neuronId: bigint) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L460)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L462)

##### :gear: autoStakeMaturity

Expand All @@ -509,7 +509,7 @@ Parameters:
- `neuronId`: The id of the neuron for which to request a change of the auto stake feature
- `autoStake`: `true` to enable the auto-stake maturity for this neuron, `false` to turn it off

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L482)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L484)

##### :gear: leaveCommunityFund

Expand All @@ -519,7 +519,7 @@ Neuron leaves the community fund
| -------------------- | ------------------------------------- |
| `leaveCommunityFund` | `(neuronId: bigint) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L496)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L498)

##### :gear: setNodeProviderAccount

Expand All @@ -530,7 +530,7 @@ Where the reward is paid to.
| ------------------------ | ---------------------------------------------- |
| `setNodeProviderAccount` | `(accountIdentifier: string) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L513)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L515)

##### :gear: mergeNeurons

Expand All @@ -540,7 +540,7 @@ Merge two neurons
| -------------- | --------------------------------------------------------------------------------- |
| `mergeNeurons` | `(request: { sourceNeuronId: bigint; targetNeuronId: bigint; }) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L533)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L535)

##### :gear: simulateMergeNeurons

Expand All @@ -550,7 +550,7 @@ Simulate merging two neurons
| ---------------------- | --------------------------------------------------------------------------------------- |
| `simulateMergeNeurons` | `(request: { sourceNeuronId: bigint; targetNeuronId: bigint; }) => Promise<NeuronInfo>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L550)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L552)

##### :gear: splitNeuron

Expand All @@ -560,7 +560,7 @@ Splits a neuron creating a new one
| ------------- | ----------------------------------------------------------------------------------- |
| `splitNeuron` | `({ neuronId, amount, }: { neuronId: bigint; amount: bigint; }) => Promise<bigint>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L595)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L597)

##### :gear: getProposal

Expand All @@ -573,7 +573,7 @@ it is fetched using a query call.
| ------------- | ----------------------------------------------------------------------------------------------------- |
| `getProposal` | `({ proposalId, certified, }: { proposalId: bigint; certified?: boolean; }) => Promise<ProposalInfo>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L635)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L637)

##### :gear: makeProposal

Expand All @@ -583,7 +583,7 @@ Create new proposal
| -------------- | ------------------------------------------------- |
| `makeProposal` | `(request: MakeProposalRequest) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L652)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L654)

##### :gear: registerVote

Expand All @@ -593,7 +593,7 @@ Registers vote for a proposal from the neuron passed.
| -------------- | ----------------------------------------------------------------------------------------------------------- |
| `registerVote` | `({ neuronId, vote, proposalId, }: { neuronId: bigint; vote: Vote; proposalId: bigint; }) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L667)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L669)

##### :gear: setFollowees

Expand All @@ -603,7 +603,7 @@ Edit neuron followees per topic
| -------------- | ------------------------------------------------- |
| `setFollowees` | `(followRequest: FollowRequest) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L689)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L691)

##### :gear: disburse

Expand All @@ -613,7 +613,7 @@ Disburse neuron on Account
| ---------- | --------------------------------------------------------------------------------------------------------------------- |
| `disburse` | `({ neuronId, toAccountId, amount, }: { neuronId: bigint; toAccountId?: string; amount?: bigint; }) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L704)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L706)

##### :gear: mergeMaturity

Expand All @@ -623,7 +623,7 @@ Merge Maturity of a neuron
| --------------- | ------------------------------------------------------------------------------------------------------- |
| `mergeMaturity` | `({ neuronId, percentageToMerge, }: { neuronId: bigint; percentageToMerge: number; }) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L743)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L745)

##### :gear: stakeMaturity

Expand All @@ -638,7 +638,7 @@ Parameters:
- `neuronId`: The id of the neuron for which to stake the maturity
- `percentageToStake`: Optional. Percentage of the current maturity to stake. If not provided, all of the neuron's current maturity will be staked.

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L776)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L778)

##### :gear: spawnNeuron

Expand All @@ -648,7 +648,7 @@ Merge Maturity of a neuron
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `spawnNeuron` | `({ neuronId, percentageToSpawn, newController, nonce, }: { neuronId: bigint; percentageToSpawn?: number; newController?: Principal; nonce?: bigint; }) => Promise<bigint>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L798)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L800)

##### :gear: addHotkey

Expand All @@ -658,7 +658,7 @@ Add hotkey to neuron
| ----------- | ------------------------------------------------------------------------------------------ |
| `addHotkey` | `({ neuronId, principal, }: { neuronId: bigint; principal: Principal; }) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L852)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L854)

##### :gear: removeHotkey

Expand All @@ -668,7 +668,7 @@ Remove hotkey to neuron
| -------------- | ------------------------------------------------------------------------------------------ |
| `removeHotkey` | `({ neuronId, principal, }: { neuronId: bigint; principal: Principal; }) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L876)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L878)

##### :gear: claimOrRefreshNeuronFromAccount

Expand All @@ -678,7 +678,7 @@ Gets the NeuronID of a newly created neuron.
| --------------------------------- | --------------------------------------------------------------------------------------- |
| `claimOrRefreshNeuronFromAccount` | `({ memo, controller, }: { memo: bigint; controller?: Principal; }) => Promise<bigint>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L897)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L899)

##### :gear: claimOrRefreshNeuron

Expand All @@ -689,7 +689,7 @@ Uses query call only.
| ---------------------- | ----------------------------------------------------------- |
| `claimOrRefreshNeuron` | `(request: ClaimOrRefreshNeuronRequest) => Promise<bigint>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L928)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L930)

##### :gear: getNeuron

Expand All @@ -699,7 +699,7 @@ Return the data of the neuron provided as id.
| ----------- | ---------------------------------------------------------------------------------------------- |
| `getNeuron` | `({ certified, neuronId, }: { certified: boolean; neuronId: bigint; }) => Promise<NeuronInfo>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L979)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/nns/src/governance.canister.ts#L981)

### :factory: ICP

Expand Down
9 changes: 7 additions & 2 deletions packages/nns/src/canisters/ledger/ledger.request.converts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,23 @@ export const toTransferRawRequest = ({
: [arrayOfNumberToUint8Array(fromSubAccount)],
});

// WARNING: When using the ICRC-1 interface of the ICP ledger, there is no
// relationship between the memo and the icrc1Memo of a transaction. The ICRC-1
// interface simply cannot set the memo field and the non-ICRC-1 interface
// cannot set the icrc1Memo field, even though the icrc1Memo field is called
// just "memo" in canister method params.
export const toIcrc1TransferRawRequest = ({
fromSubAccount,
to,
amount,
fee,
memo,
icrc1Memo,
createdAt,
}: Icrc1TransferRequest): Icrc1TransferRawRequest => ({
to,
fee: toNullable(fee ?? TRANSACTION_FEE),
amount,
memo: toNullable(memo),
memo: toNullable(icrc1Memo),
created_at_time: toNullable(createdAt),
from_subaccount: toNullable(fromSubAccount),
});
4 changes: 3 additions & 1 deletion packages/nns/src/governance.canister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ export class GovernanceCanister {

// Send amount to the ledger.
await ledgerCanister.icrc1Transfer({
memo: nonceBytes,
// WARNING: This does not set the same memo field as the stakeNeuron
// function above and would need to be handled separately from that field.
icrc1Memo: nonceBytes,
amount: stake,
fromSubAccount,
to: {
Expand Down
Loading

0 comments on commit 03ed6b2

Please sign in to comment.