ref-finance / ref-contracts

Smart contracts for Ref Finance
MIT License
96 stars 55 forks source link

Improve upgrading capability by removing parsing/loading #25

Closed referencedev closed 3 years ago

referencedev commented 3 years ago

This reduces amount of gas used and makes it compatible with Sputnik DAO UpdateRemote.

Usage from CLI:

> near repl
const fs = require('fs');
const account = await near.account("<account>");
const newContract = fs.readFileSync("<path>");
const result = account.signAndSendTransaction(
    <contract>,
    [
        nearAPI.transactions.functionCall("upgrade", newContract, 20000000000000, "0"),
    ]);

Example: https://explorer.testnet.near.org/transactions/GLwdTBVTrguY7mERg997MK5mxnfbAkVgW78sKPprhMge

robert-zaremba commented 3 years ago

It looks like a low level optimization. what's the improvement? 10x? if so it's worth to do. If it's a small reduction, then probably it's better to stick with high level functions.

referencedev commented 3 years ago

The main benefit is that this works with Sputnik DAO. Optimization Which means Sputnik can be the owner of the Ref and vote to upgrade it.