Skip to content

Latest commit

 

History

History
78 lines (62 loc) · 2.96 KB

README.md

File metadata and controls

78 lines (62 loc) · 2.96 KB

ORAI SWAP - Uniswap V3 in CosmWasm

  ░░
░░░░              ░░░░░░
░░░░  ░░            ░░░░░░
░░░░  ░░        ░░    ░░▒▒
░░░░░░▒▒          ░░▒▒░░▒▒
  ░░▒▒                ░░▒▒
    ░░▒▒  ░░░░░░░░  ░░▒▒
      ░░░░░░░░░░░░░░░░
    ░░░░░░░░██░░██░░░░░░
    ▒▒░░░░░░░░░░░░░░░░▒▒
  ░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░
  ░░░░  ▒▒░░    ░░▒▒  ░░░░
  ░░    ▒▒        ▒▒    ░░


                                ,,)))))));,
                                __))))))))))))));,
                            -\(((((''''((((((((
                    --==//////((''  .     `)))))),
                            ))| @    ;-.     (((((
                            ( `|    /  )      )))/- ----------_\__---~~__--~~--_
                                |   |   |       (/      ---~~~/__-----~~  ,;::'  \         ,
                                o_);   ;        /      ----~~/           \,-~~~\  |       /|
                                    ;        (      ---~~/         `:::|      |;|      < >
                                    |   _      `----~~~~'      /      `:|       \;\_____//
                                ______/\/~    |                 /        /         ~------~
                            /~;;.____/;;'  /          ___----(   `;;;/
                            / //  _;______;'------~~~~~    |;;/\    /
                            //  | |                        /  |  \;;,\
                        (<_  | ;                      /',/-----'  _>
                            \_| ||_                     //~;~~~~~~~~~
                                `\_|                   (,~~
                                                        \~\
                                                        ~~

build wasm sdk

cd wasm && wasm-pack build --features tsify/js

convert all wasm_bingen to camel case

node convert.js

const { readdirSync, readFileSync, writeFileSync } = require('fs');
const { join } = require('path');

function walk(dir, ext = '.rs') {
  return readdirSync(dir, { withFileTypes: true })
    .flatMap((file) => (file.isDirectory() ? walk(join(dir, file.name), ext) : file.name.endsWith(ext) ? join(dir, file.name) : null))
    .filter(Boolean);
}

const reg = /(?<=#\[wasm_bindgen)\]([\n\t\s])+(?=pub\s+fn\s+([\w_]+)\()/g;

const rustFiles = walk('wasm');

for (const file of rustFiles) {
  const fileContent = readFileSync(file)
    .toString()
    .replace(reg, (_, g1, g2) => {
      const fnName = g2
        .split('_')
        .map((part, i) => (i > 0 ? part[0].toUpperCase() + part.substr(1) : part))
        .join('');
      return `(js_name = ${fnName})]${g1}#[allow(non_snake_case)]${g1}`;
    });

  writeFileSync(file, fileContent);
}