stakeordie / griptape.js Goto Github PK
View Code? Open in Web Editor NEWGriptape is a framework for developing dApps on Secret Network.
Home Page: https://griptapejs.com
License: MIT License
Griptape is a framework for developing dApps on Secret Network.
Home Page: https://griptapejs.com
License: MIT License
Server Side querying of public universal data. Example: n/900 minted.
When calling a contract, sometimes the respond contains valuable information that could be used for example, to improve UI/UX. The issue here is that the current secretjs implementation, returns a data
property as an array of integers (bytes). One way to handle and properly decode these set of integer could be as follows:
const decoder = new TextDecoder('utf-8');
const raw = await sefi.createViewingKey();
const decoded = decoder.decode(raw.data);
if (decoded) {
const res = JSON.parse(decoded);
viewingKeyManager.add(sefi, res.create_viewing_key.key);
}
That being said, there should be a way of:
data
propertyIn order to do that, I propose the following API:
interface ContractResponse {
get: () => object;
getRaw: () => object;
isEmpty: () => boolean;
}
Please update the documentation bro.. please.
i got some error during run time.
https://github.com/stakeordie/griptape-docs/tree/main/docs/tutorial
When using Griptape.js in TypeScript, add
method in ViewingKeyManager
class has the wrong type for contracts, therefore you get a type error in TypeScript.
Steps to reproduce the behavior:
ViewingKeyManager
instance to add a viewing for that contract instance.Expected behavior
There should be no error.
create common types between modules in types.ts
file and remove them from specific modules
This feature request is for adding to the Contracts API a contract registry. The purpose of the contract registry is to hold all the instances of a particular contract, such that you are able to get that contract through an API rather that accessing to the itself.
Here's and example of how that API will look:
import {
snip20Def,
createContract,
getContract
} from '@stakeordie/griptape.js';
const stkd = createContract(...);
const list = getSnip20s(); // [ { symbol: '...', address: '...' } ]
list.forEach(({ symbol: id, address: at }) => {
const spec = { id, at, definition: snip20Def };
createContract(spec);
})
getContract('sefi').getBalance();
getContract('stkd').getBalance();
getContract('stkd') === stkd // true
When calling contracts, adjust transferAmount
to receive an Object rather than an array:
doTx() {
const transferAmount = { amount: '...', denom: '...' };
return { transferAmount };
}
Complete the implementation of the contract definition for the SNIP-20 spec.
References:
Add to src/index.ts
the export for the src/events/index.ts
file:
export * from './events/index.ts';
Also export everything for all other modules in the src/events
in the src/events/index.ts
file, like:
export * from './accounts';
So we can do this:
import {
Callback
} from '@stakeordie/griptape.js';
Callback
to EventCallback
CleanListenerCallback
CleanListenerCallback
export type CleanListenerCallback = () => void;
Deprecate create contract function by adding the proper JSDoc.
Add support for multi transactions based on the multiExecute
API on secretjs
.
The API might look like this:
const sefi = createContract(...);
multiMessage([
message(sefi.send),
message(sefi.transfer, arg1, arg2)
])
Pretty self-explanatory.
When using the viewingKeyManager.add
and as the second argument you pass undefined
, you don't get any error,
and a viewing key gets added without key
.
To Reproduce
viewingKeyManager
from @stakeordie/griptape.js
viewingKeyManager.add
method and pass undefined
as the second parameterlocalStorage
Expected behavior
It should throw an error due to the fact that you are adding an undefined viewing key.
As an API grows, I find valuable to being able to use only specific parts of the API by using nodejs subpath exports.
This means, the API should be imported in a submodule fashion:
import { refContract } from '@stakeordie/griptape.js/contracts';
import { snip20def } from '@stakeordie/griptape.js/contracts/definitions'
message
to buildMessage
multiMessage
to executeMultiMessage
padding
make it 32 lengthentropy
make it 32 length and encode it to base64Write a draft for all the different APIs and deploy them to https://docs.griptapejs.com.
secretjs has methods for getting contracts and instantiated them like, mostly those on SigningCosmWasm
:
interface SigningCosmWasmClient {
instantiate(
codeId: number,
initMsg: object,
label: string,
memo?: string,
transferAmount?: readonly Coin[],
fee?: StdFee,
contractCodeHash?: string,
): Promise<InstantiateResult>;
}
Lets expose those features to be able to manage contracts (upload code, instantiate and get them from the blockchain)
Add a wrapped version of the Viewing Keys API to enable users to create viewing keys using Keplr and pass them into the current Viewing Keys API:
import { keplrViewingKeyManager as vks } from '@stakeordie/griptape.js';
const sefi = ...
const key = ...
vks.add(sefi, key);
Change the type of fees
property to be number
and calculate the fees based on the following function:
const gasPriceUscrt = 0.25;
export function getFeeForExecute(gas: number): StdFee {
return {
amount: [
{ amount: String(Math.floor(gas * gasPriceUscrt) + 1), denom: "uscrt" },
],
gas: String(gas),
};
}
So then, you can do:
const stkd = {
messages: {
stake() {
const handleMsg = { stake: { } };
const fees = 650000;
return { handleMsg, fees };
}
}
}
Add a method to unsubscribe from an event, something like:
const unsubscribe = onAccountAvailable(
() => console.log('Account available!'));
unsubscribe(); // remove the last callback
JSON to TypeScript: https://jsonformatter.org/json-to-typescript
Secret API: https://secretapi.io/#/
This base class should handle the following:
class BlockchainModule {
client: AxiosInstance;
constructor(baseURL: string) {
this.client = axios.create({ baseURL });
}
}
Basically is a renaming of the deprecated createContract
function.
Add support for SNIP-741 contract definition.
When calling getAddress
on the onAccountChange
it doesn't refresh the account and therefore, cannot query or execute any message for a contract.
When trying to define an empty contract definition, you get an error in TypeScript, e.g.
const def = {};
Expected result
queries
and/or messages
should be optional.
When executing a contract, there is some SNIP-20 specific code that handles and warns the user if they are not providing either an address or key for a specific query as follows:
griptape.js/src/contracts/index.ts
Lines 104 to 114 in a0d0f94
We should remove this and maybe provide and API to handle specific scenarios in which we want to prevent the execution of a query.
Some messages require and entropy
as describe in some of the SNIP-20 specification.
Let's remove the responsibility of the user of the Contracts API to provide that piece of data by adding entropy
as part of the Contracts API context. So the final interface for the context will be:
export interface Context {
address?: string;
key?: string;
padding?: string;
height?: number;
entropy: string;
}
The signature of the function should be like this:
export async function getBalance(): Promise<string>;
This function should do:
onShutdown
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.