Skip to content

Commit

Permalink
Feat/use fpass (#24)
Browse files Browse the repository at this point in the history
* Add example for Fee Preferences and proxy extrinsic which is a fpass proxy call

* As per review comments

* Undo changes in use-forge package json

* Change endpoint

* Update examples/substrate/use-feeProxy/src/feeProxyWithProxyExtrinsic.ts

Co-authored-by: Ken Vu <[email protected]>

* Code formating

* Add example for Fee Preferences and proxy extrinsic which is a fpass proxy call

* As per review comments

* Undo changes in use-forge package json

* Fpass proxy extrinsic transfer fpass

* Format

* Format

---------

Co-authored-by: Ken Vu <[email protected]>
  • Loading branch information
KarishmaBothara and ken-futureverse authored Aug 16, 2023
1 parent 74defd4 commit b11d4fb
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { createKeyring } from "@trne/utils/createKeyring";
import { filterExtrinsicEvents } from "@trne/utils/filterExtrinsicEvents";
import { getChainApi } from "@trne/utils/getChainApi";
import { sendExtrinsic } from "@trne/utils/sendExtrinsic";
import { cleanEnv, str } from "envalid";

const env = cleanEnv(process.env, {
CALLER_PRIVATE_KEY: str(), // private key of extrinsic caller
});

export async function main() {
const api = await getChainApi("porcini");
const caller = createKeyring(env.CALLER_PRIVATE_KEY);
const newOwner = "0x0E17C1a78d2A77298Df58e5956B33376A1B9f4c2";

const futurepass = (await api.query.futurepass.holders(caller.address)).toString();
// transfer futurepass
const call = api.tx.futurepass.transferFuturepass(caller.address, newOwner);

const extrinsic = api.tx.futurepass.proxyExtrinsic(futurepass, call);

const { result } = await sendExtrinsic(extrinsic, caller, { log: console });
const [proxyEvent, fpassTransferred] = filterExtrinsicEvents(result.events, [
"Futurepass.ProxyExecuted",
"Futurepass.FuturepassTransferred",
]);

console.log("Extrinsic Result", {
proxy: proxyEvent.toJSON(),
fpassTransferred: fpassTransferred.toJSON(),
});

await api.disconnect();
}

main();

0 comments on commit b11d4fb

Please sign in to comment.