Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade web sdk #395

Merged
merged 33 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
68ce07c
Update wallet-api
soerenbf Oct 13, 2023
9f49a05
Use strong types in API
soerenbf Oct 13, 2023
4b16d61
Build works
soerenbf Oct 16, 2023
19fdfac
Typechecks
soerenbf Oct 16, 2023
d5d04bf
Compatibility for smart contract transactions
soerenbf Oct 16, 2023
a53517b
Compatibility for all account transaction payloads
soerenbf Oct 16, 2023
25fec40
Fix earn flow
soerenbf Oct 17, 2023
f21318d
Fix tests
soerenbf Oct 17, 2023
d1e77a4
Hide GRPC client from wallet API, expose wallet GRPC transport instead
soerenbf Oct 17, 2023
688e922
Fix recovery
soerenbf Oct 17, 2023
e5cf0b9
Upgrade web sdk beta
soerenbf Oct 17, 2023
bdd5232
Add GRPC transport getter to api interface
soerenbf Oct 17, 2023
d136fad
Cleanup
soerenbf Oct 17, 2023
8cc129a
Fix examples
soerenbf Oct 18, 2023
77fb86e
Up esbuild (fixes resolve issue)
soerenbf Oct 18, 2023
74e8080
Up @concordium/react-components to beta version
soerenbf Oct 18, 2023
d750583
Fix compatibility layer
soerenbf Oct 18, 2023
73b797a
Downgrade @concordium/react-components to make compatible with currently
soerenbf Oct 18, 2023
b8a45ff
Setup vite for wccd
soerenbf Oct 18, 2023
a39e77d
Up @concordium/react-components
soerenbf Oct 18, 2023
b11c451
Fix build:all
soerenbf Oct 18, 2023
62f95e3
Enable gzip for wccd
soerenbf Oct 19, 2023
66b6320
Up SDK beta
soerenbf Oct 19, 2023
0f233ff
Update web sdk
soerenbf Oct 19, 2023
447fb60
Upgrade e-sealing
soerenbf Oct 20, 2023
dfca66e
Update piggy bank
soerenbf Oct 20, 2023
69472f9
gzip wasm
soerenbf Oct 20, 2023
16183ea
Fix missing build + more gzip
soerenbf Oct 21, 2023
66272c4
PR feedback
soerenbf Oct 25, 2023
2a29a76
Unit tests for wallet API compatibility
soerenbf Oct 25, 2023
7a10da3
Clean up baker version type predicate
soerenbf Oct 27, 2023
11d9690
UPdate common helpers
soerenbf Oct 27, 2023
3710e27
Version bump + readme alignment
soerenbf Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ dist
package.json
!.storybook

packages/browser-wallet-api-helpers/lib
packages/browser-wallet-api-helpers/lib
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module.exports = {
ecmaFeatures: {
jsx: true,
},
project: 'tsconfig.json',
createDefaultProgram: true,
project: ['./tsconfig.json', './packages/browser-wallet/tsconfig.eslint.json', './examples/*/tsconfig.json'],
tsconfigRootDir: __dirname,
},
env: {
browser: true,
Expand Down
2 changes: 1 addition & 1 deletion examples/add-example-Web3Id/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"start": "live-server ./index.html --mount=/sdk.js:../../node_modules/@concordium/web-sdk/lib/concordium.min.js --mount=/helpers.js:../../packages/browser-wallet-api-helpers/lib/concordiumHelpers.min.js"
},
"dependencies": {
"@concordium/web-sdk": "^6.3.0"
"@concordium/web-sdk": "^7.0.0"
}
}
6 changes: 4 additions & 2 deletions examples/eSealing/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ FROM ${base_image} AS build
WORKDIR /app
COPY ./package.json ./package.json
COPY ./tsconfig.json ./tsconfig.json
COPY ./esbuild.config.ts ./
COPY ./types ./types
COPY ./index.html ./
COPY ./vite.config.ts ./
COPY ./public ./public
COPY ./src ./src

RUN yarn && yarn cache clean
RUN yarn build

FROM nginx
COPY --from=build ./app/dist ./usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
orhoj marked this conversation as resolved.
Show resolved Hide resolved
63 changes: 0 additions & 63 deletions examples/eSealing/esbuild.config.ts

This file was deleted.

22 changes: 22 additions & 0 deletions examples/eSealing/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url(/esealing_bg.jpeg);
background-color: #1e1e1e;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}
</style>

<link rel="icon" type="image/x-icon" href="/concordium_favicon.svg" />
<meta charset="utf-8" />
</head>

<body>
<div id="root"></div>
<script src="src/index.tsx" type="module"></script>
</body>
</html>
42 changes: 42 additions & 0 deletions examples/eSealing/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Enable Gzip
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/json
application/xml
application/wasm
application/rss+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml
image/jpeg;

gzip_static on;

gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;

server {
listen 80 default;
server_name _;
root /usr/share/nginx/html;

# Set expires max on static file types
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm|wasm)$ {
expires max;
root /usr/share/nginx/html;
access_log off;
}
}
26 changes: 12 additions & 14 deletions examples/eSealing/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "e_sealing",
"packageManager": "[email protected]",
"version": "1.1.2",
"version": "1.1.3",
"license": "Apache-2.0",
"dependencies": {
"@concordium/react-components": "^0.3.0",
"@concordium/web-sdk": "^6.3.0",
"@concordium/react-components": "0.4.0-rc.5",
orhoj marked this conversation as resolved.
Show resolved Hide resolved
"@concordium/web-sdk": "^7.0.0",
"@thi.ng/leb128": "^2.1.18",
"@types/sha256": "^0.2.0",
"@walletconnect/types": "^2.1.4",
Expand All @@ -16,22 +16,20 @@
"sha256": "^0.2.0"
},
"devDependencies": {
"@craftamap/esbuild-plugin-html": "^0.4.0",
"@types/node": "^18.7.23",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.5",
"cross-env": "^7.0.3",
"esbuild": "^0.14.42",
"esbuild-plugin-svgr": "^1.0.1",
"fs": "^0.0.1-security",
"live-server": "^1.2.2",
"@vitejs/plugin-react-swc": "^3.4.0",
"process": "^0.11.10",
"ts-node": "^10.8.0",
"typescript": "^5.2.2"
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vite-plugin-svgr": "^4.1.0",
"vite-plugin-top-level-await": "^1.3.1",
"vite-plugin-wasm": "^3.2.2"
},
"scripts": {
"build": "node --loader ts-node/esm ./esbuild.config.ts; cp ./src/assets/* ./dist",
"watch": "cross-env WATCH=1 yarn build",
"start": "live-server ./dist"
"build": "tsc && vite build",
"dev": "vite",
"start": "vite preview"
}
}
Binary file added examples/eSealing/public/esealing_bg.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions examples/eSealing/src/assets/Concordium_background.svg

This file was deleted.

19 changes: 12 additions & 7 deletions examples/eSealing/src/eSealing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import {
deserializeReceiveReturnValue,
serializeUpdateContractParameters,
ConcordiumGRPCClient,
ContractName,
EntrypointName,
ContractAddress,
ReceiveName,
ReturnValue,
} from '@concordium/web-sdk';
import sha256 from 'sha256';
import { useGrpcClient, TESTNET, WalletConnectionProps, useConnection, useConnect } from '@concordium/react-components';
Expand Down Expand Up @@ -96,15 +101,15 @@ const InputFieldStyle = {

async function viewFile(rpcClient: ConcordiumGRPCClient, fileHashHex: string) {
const param = serializeUpdateContractParameters(
E_SEALING_CONTRACT_NAME,
'getFile',
ContractName.fromString(E_SEALING_CONTRACT_NAME),
EntrypointName.fromString('getFile'),
fileHashHex,
toBuffer(E_SEALING_RAW_SCHEMA, 'base64')
);

const res = await rpcClient.invokeContract({
method: `${E_SEALING_CONTRACT_NAME}.getFile`,
contract: { index: E_SEALING_CONTRACT_INDEX, subindex: CONTRACT_SUB_INDEX },
method: ReceiveName.fromString(`${E_SEALING_CONTRACT_NAME}.getFile`),
contract: ContractAddress.create(E_SEALING_CONTRACT_INDEX, CONTRACT_SUB_INDEX),
parameter: param,
});

Expand All @@ -115,10 +120,10 @@ async function viewFile(rpcClient: ConcordiumGRPCClient, fileHashHex: string) {
}

const returnValues = deserializeReceiveReturnValue(
toBuffer(res.returnValue, 'hex'),
ReturnValue.toBuffer(res.returnValue),
toBuffer(E_SEALING_RAW_SCHEMA, 'base64'),
E_SEALING_CONTRACT_NAME,
'getFile',
ContractName.fromString(E_SEALING_CONTRACT_NAME),
EntrypointName.fromString('getFile'),
2
);

Expand Down
19 changes: 0 additions & 19 deletions examples/eSealing/src/index.html

This file was deleted.

13 changes: 5 additions & 8 deletions examples/eSealing/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createContext } from 'react';
import { AccountTransactionType, CcdAmount } from '@concordium/web-sdk';
import { AccountTransactionType, CcdAmount, ContractAddress, Energy, ReceiveName } from '@concordium/web-sdk';
import { WalletConnection, moduleSchemaFromBase64 } from '@concordium/react-components';
import { E_SEALING_CONTRACT_NAME, E_SEALING_RAW_SCHEMA } from './constants';

Expand All @@ -17,13 +17,10 @@ export async function register(
account,
AccountTransactionType.Update,
{
amount: new CcdAmount(BigInt(0n)),
address: {
index,
subindex,
},
receiveName: `${E_SEALING_CONTRACT_NAME}.registerFile`,
maxContractExecutionEnergy: 30000n,
amount: CcdAmount.fromMicroCcd(0),
address: ContractAddress.create(index, subindex),
receiveName: ReceiveName.fromString(`${E_SEALING_CONTRACT_NAME}.registerFile`),
maxContractExecutionEnergy: Energy.create(30000n),
},
{
parameters: fileHashHex,
Expand Down
12 changes: 4 additions & 8 deletions examples/eSealing/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@
"compilerOptions": {
"target": "ES2020",
"lib": ["dom", "dom.iterable", "esnext"],
"baseUrl": ".",
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"downlevelIteration": true,
"baseUrl": ".",
"noEmit": true,
"jsx": "react"
},
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
"jsx": "react",
"types": ["vite-plugin-svgr/client"]
},
"include": ["./**/*"]
}
1 change: 0 additions & 1 deletion examples/eSealing/types/svg.d.ts

This file was deleted.

21 changes: 21 additions & 0 deletions examples/eSealing/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import svgr from 'vite-plugin-svgr';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';

export default defineConfig({
plugins: [
react(),
svgr(),
wasm(),
topLevelAwait(), // For legacy browser compatibility
],
resolve: {
alias: {
'@concordium/rust-bindings': '@concordium/rust-bindings/bundler', // Resolve bundler-specific wasm entrypoints.
},
},
});
30 changes: 9 additions & 21 deletions examples/nft-minting/esbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,12 @@ const config: BuildOptions = {
],
};

if (watch) {
config.watch = {
onRebuild(error) {
if (error) {
console.error('watch build failed:', error);
return;
}

console.log('rebuild successful');
},
};
}

esbuild
.build(config)
.then(() => {
if (watch) {
console.log('watching for changes...');
}
})
.catch(() => process.exit(1));
(async () => {
if (watch) {
const ctx = await esbuild.context(config);
await ctx.watch();
console.log('watching for changes...');
} else {
esbuild.build(config).catch(() => process.exit(1));
}
})();
Loading
Loading