Git Product home page Git Product logo

agent_dart's People

Contributors

alexv525 avatar iota9star avatar neeboo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agent_dart's Issues

Connection refused when fetching status for root key of local replica

I'm encountering this error when calling fetchRootKey() of HttpAgent in _initAgent():

E/flutter (23155): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: http request failed because SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 46950
E/flutter (23155): #0 HttpAgent._defaultFetch (package:agent_dart/agent/agent/http/index.dart:433:7)
E/flutter (23155):
E/flutter (23155): #1 HttpAgent.status (package:agent_dart/agent/agent/http/index.dart:362:20)
E/flutter (23155):
E/flutter (23155): #2 HttpAgent.fetchRootKey (package:agent_dart/agent/agent/http/index.dart:246:20)
E/flutter (23155):
E/flutter (23155): #3 AgentFactory._initAgent (package:agent_dart_example/init.dart:63:7)
E/flutter (23155):
E/flutter (23155):

This means that the port somehow gets changed since I specified port 40161 in the url of the AgentFactory (this is where my local replica runs).
I also tried to directly set the port with the host parameter of HttpAgentOptions but still get the same error.

Am I missing something?

Add support for pure dart projects.

Right now the project has a dependency on flutter thus it's not possible to use the package on a pure dart environment like a server-side dart.

Package behaves more like agent_flutter rather than agent_dart.

i am having this error "SingingBlockZipFileEncoder.close" is void

Error (Xcode): ../../../.pub-cache/hosted/pub.dev/agent_dart-1.0.0-dev.22/lib/archiver/encoder.dart:162:8: Error: The return type of the method 'SingingBlockZipFileEncoder.close' is 'void', which does not match the return type, 'Future', of the overridden method, 'ZipFileEncoder.close'.

Error while creating an actor

This is the error that I am getting while creating an actor

ArgumentError: Invalid argument(s): Failed to lookup symbol 'bls_verify': dlsym(RTLD_DEFAULT, bls_verify): symbol not found

Full Stack Trace:

ArgumentError: Invalid argument(s): Failed to lookup symbol 'bls_verify': dlsym(RTLD_DEFAULT, bls_verify): symbol not found
  File "ffi_dynamic_library_patch.dart", line 34, in DynamicLibrary.lookup
  File "ffi_base.dart", line 23, in rustBlsVerify
  File "bls.ffi.dart", in FFIBls.blsVerifySync
  File "certificate.dart", line 155, in Certificate.verify
  File "<asynchronous suspension>"
  File "certificate.dart", line 179, in Certificate._checkDelegation
  File "<asynchronous suspension>"
  File "certificate.dart", line 149, in Certificate.verify
  File "<asynchronous suspension>"
  File "index.dart", line 17, in pollForResponse
  File "<asynchronous suspension>"
  File "actor.dart", line 432, in _createActorMethod.<fn>

If it helps, my app communicates with a dozen dynamic canisters and creates dozen of actors using this common method

  Future<CanisterActor> getVideoCanisterActor(String canisterId) async {
    if (_canisters[canisterId] == null) {
      AgentFactory _videoCanisterAgent = await AgentFactory.createAgent(
        canisterId: canisterId,
        url: backendUrl,
        idl: videoCanisterIDL,
      );
      _canisters[canisterId] = _videoCanisterAgent.actor!;
    }
    return _canisters[canisterId]!;
  }

[Bounty]Documentation for agent_dart apis

Description

Documentation for agent_dart apis

Context

To have better understanding of internet computer, for client developers, it is the best way to understand how the sdk works.

Though we have ported most agent-js features to agent_dart, we don't have enough resources to complete the api docs. Which is really important work for community developers.

Thus, we need to cover as many apis as possible, we need someone to comment on code like we do for dart code.

Acceptance Criteria

  • [comment on code to cover all apis]
  • [generate dart docs]
  • [optional generate gitbook or github pages]
  • [optional tutorial/docs site for developers]

Reward

[20 ICPs, with 10 ICPs bonus for docs site]

[Web] Http response error: http request failed because Error on line 1, column 17: Invalid media type: expected no more input.

Error

1 โ”‚ application/cbor, application/cbor

Description:

While execute with update and query call using flutter web, the IC behaves differently between Native and Web, which is on the Web, IC (mainnet) may return dual headers to the client, somehow it's
However, agent_dart using flutter/dart's official http package to make the requests internally. Although the Response class from Http returns normally, however, while using Response.body to get a string( in order to display non-bytes error or message), the MediaType.parse function will throw error since it only supports single type Media type.

Fix:
To set Response.headers manually ,only accept the first content-type and discard the rest, before getting the body string.

if (postResponse.headers["content-type"] != null &&

How do we report security issues?

Hi,

My name is Eduard, I work in Dfinity's product security team. During one of our internal reviews we've found some security issues in agent_dart. What would be the best way to share the findings with you?

Thanks in advance!

[Bounty] Candid builder for dart class

Description

To build a candid builder for agent dart

Context

Candid is used to describe IDL for canister functions.
Candid builder is used to transform candid files to usable functions/classes for agent clients in different languages.
For dart language, all interfaces are classes. To make a workable builder, like we do json decoding classes, candid builder should also transform all those interfaces into classes.

Candid files are trans-compiled into typescript and javascript using didc, link is here

There are repos maintained by community for other languages:

  1. Kotlin
  2. Haskell
  3. AssemblyScript
  4. elm

Since agent_dart is ported agains agent-js, all IDL interfaces and styles are very similar to javascript/typescript.

for example , in generarted javascript:

const Purpose = IDL.Variant({
    'authentication' : IDL.Null,
    'recovery' : IDL.Null,
});
const CredentialId = IDL.Vec(IDL.Nat8);

in agent_dart, we can almost simply copy paste

final Purpose = IDL.Variant({
    'authentication' : IDL.Null,
    'recovery' : IDL.Null,
});
final CredentialId = IDL.Vec(IDL.Nat8);

So we might be able to :

  1. modify and use didc to generate those idl,
  2. THEN write classes using dart builder

To see working classes in dart, please refer to wallet/ledger.dart

Acceptance Criteria

  • modify and combine didc to builder to generate idls
  • use dart builder to generate artifacts in dart classes
  • tests and working examples, published to other repo.

Reward

30 ICPs

Documentation for reference, usage, example

There are differences between agent_dart and agent-js, we can not rely developers understand all features of agent-js.

updates

  1. use dart doc to reference the docs
  2. write tutorial and guides in the next milestones

Hence we have to make documentation for reference, usage, example.
So we have to document or lit on the code, and later we may use github page to host a example code static site.
[ ] lit the code with comments and usage code.
[ ] write a static doc site and publish with github page

Projects using agent_dart

Feel free to submit your projects here, and we will move them to README, and later to doc site

Template below:


  • Project Name

My very cool project

  • Project Type

Defi DApp/Wallet/Metaverse/Social DApps/Open Service/Tooling....

  • Description

Your project description

  • Official Website

If available

  • Download Link/Market URI

If available, Google Play/ Apple AppStore/ other URL


Error with Delegation Identity

Hello,

When I try to use IC identity (using local page), I got a normal identity, and the result is like in the example project in this lib. After that, I am calling the IC canister, and I got an error.
Error:
Unhandled Exception: Unhandled error Server returned an error: Code: 403 (Forbidden)

Body: Failed to authenticate request 0x5f5b53a270e40c4558549975f54c17163b24b337054255bc1c2e56705fab9860 due to: Invalid delegation: Invalid canister signature: IcCanisterSignature signature could not be verified: public key 0a000000000000000701012ad6fa197bcc32c16f588d58ccb0468c9bd039c9b60302ad08e03cda98f6243f, signature d9d9f7a26b63657a9.......678301820458200e729de08c6bfa677847fb8d7bcc79efc892045aed2c4b350f7c7446085257f5830182045820b71837514f52507ff04caee7b05a920f1d5ac8863b9d65d3489951ff33b1187e83025820f487586c5bdaaa19d6f10abc3626e44af4624a386c64832659da432f265a61f5830258208b8ee0cf244a56d1b8fa863141be1b473f9e0576d941282124d41e2b44793519820340, error: the signature tree doesn't contain sig/f487586c5bdaaa19d6f10abc3626e44af4624a386c64832659da432f265a61f5/2baf862838777c8dfc951a5b4b3768b5ce23bc641ea0a1172f3e0726de7ae936

I don't have any problem with normal identity (created by myself), but this Delegation one made this error.

Do you have some idea how to solve this problem?

Getting `Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)` on Xcode 15.0.1

๐Ÿ‘‹ We had a couple of our Flutter SDK developers bring up the parseErrorData issue #70 and ask us to upgrade to the latest version of agent_dart: ^1.0.0-dev.18 to bypass the error.

Unfortunately, doing so leads to the following error with Xcode:

Screenshot 2023-11-06 at 5 06 48โ€ฏPM

Here's how the error looks like on my terminal ๐Ÿ‘‡ :

Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)


Could not build the application for the simulator.
Error launching application on iPhone 15 Pro Max.

When I attempt to add CoreAudioTypes.framework to the flutter project inside of Xcode I'm met with this warning: CoreAudioTypes.framework is not supported on Mac Catalyst. ๐Ÿค”

Screenshot 2023-11-06 at 5 08 57โ€ฏPM

We've tried every which way to bypass the above error:

  • Removed Mac Catalyst support from all dependencies
  • Added the Audio Types to agent_dart directly vs the Runner target
    etc etc.

As it stands we are unable to run our demo flutter app on iOS (Android works fine ๐Ÿ˜Œ) with agent_dart: ^1.0.0-dev.18 and switching back to the older version brings back issue #70. Please help ๐Ÿ™

Rejected by IC when using a tuple type as a call parameter

The error is as follows, but the official agent-js will not have this problem.

I/flutter ( 8497): PollingResponseRejectedException
I/flutter ( 8497): Call was rejected:
I/flutter ( 8497): Request ID: f940e19fa2301477b4e46de087195d03b36105aadc35961feb95a880fb9684d8
I/flutter ( 8497): Reject code: ๏ฟฝ
I/flutter ( 8497): Reject msg: Canister rdmx6-jaaaa-aaaaa-aaadq-cai trapped explicitly: IDL error: did not find tuple field in record

Required named parameter 'parseErrorData' must be provided.

Hi, we upgraded to latest flutter and use magic sdk which depends on agent_dart. We ran into the following issue:

../../../../../.pub-cache/hosted/pub.dev/agent_dart-1.0.0-dev.17/lib/bridge/ffi/ffi_bridge.dart:461:57: Error:
Required named parameter 'parseErrorData' must be provided.
This comes from agent_dart which is referenced in the magic sdk. I tried to pinpoint the agent_dart version and this error shows up for the first time in '1.0.0-dev.15' - Also posted within the magic sdk -> magiclabs/magic-flutter#45

agent_dart is v 1.0.0-dev.17
magic is 4.1.3

[โœ“] Flutter (Channel stable, 3.13.7, on macOS 13.5.1 22G90 darwin-arm64, locale en-US)
[โœ“] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[โœ“] Xcode - develop for iOS and macOS (Xcode 15.0)
[โœ“] Chrome - develop for the web
[โœ“] Android Studio (version 2021.2)
[โœ“] VS Code (version 1.83.0)
[โœ“] Connected device (3 available)
[โœ“] Network resources

Internet Identity provider url in v1.0.0-dev.17 needs to be updated to https://identity.ic0.app/

In agent_dart v1.0.0-dev.17, 'const identityProviderDefault = 'https://identity.icp0.io'' is used in auth_client for Internet Identity login.

However, this setting causes Internet Identity to throw an error stating '...did not resolve to a canister ID.' I confirmed this by comparing it with the latest versions of agent-js and agent_dart 0.1.24+1, both of which use 'https://identity.ic0.app/' and it function as expected.

See the attached screenshot for reference."

agent-js
Error 1
Error 2

how to send icp to an account

I want to send icp to account: 1586275a55430abba47862989da56f2c9ac31bc9f1c58739d6637a33714f307a
Here is my code:
var mne ='xxx';
var p = RosettaApi();
var key = fromMnemonicWithoutValidation(mne, []);
await p.init();
var pre = await p.transferPreCombine(
key.getPublicKey().toRaw(),
hex.HEX.decode(
'1586275a55430abba47862989da56f2c9ac31bc9f1c58739d6637a33714f307a'),
BigInt.from(90000),
BigInt.from(10000),
{});
var s = await transferCombine(key, pre);
var res = await p.transfer_post_combine(s);
print(res);

But when I run code above, I get some error. Could you please give me a code example, thanks.

Exception: Subclasses of `FlutterRustBridgeBase` should be singletons - there should not be two instances (runtimeType=AgentDartImpl)

agent_dart
Branch: 1.0.0-dev
Commit: 0b39334

Stack Trace:

_Exception: Exception: Subclasses of `FlutterRustBridgeBase` should be singletons - there should not be two instances (runtimeType=AgentDartImpl)
  File "basic.dart", line 28, in FlutterRustBridgeBase._sanityCheckSingleton
  File "basic.dart", line 19, in new FlutterRustBridgeBase
  File "ffi_bridge.dart", line 314, in new AgentDartImpl.raw
  File "ffi_bridge.dart", line 312, in new AgentDartImpl
  File "ffi_helper.dart", line 40, in new AgentDartFFI._
  File "ffi_helper.dart", line 50, in AgentDartFFI._instance
  File "ed25519.dart", in Ed25519KeyIdentity.generate
  File "auth_client.dart", line 212, in AuthClient.login
  File "login.dart", line 61, in _LoginScreenState._loginUsingII

The exact function that caused the issue is Ed25519KeyIdentity.generate from AuthClient package.

ZipFileEncoder.zipDirectory error

After just:

  • creating a flutter project
  • flutter pub add agent_dart
  • flutter pub add agent_dart_auth
  • flutter pub add file

I get the following error

../../.pub-cache/hosted/pub.dev/agent_dart-0.1.24+1/lib/archiver/encoder.dart:74:8: Error: The method 'SingingBlockZipFileEncoder.zipDirectory' has fewer named arguments than those of overridden method 'ZipFileEncoder.zipDirectory'.
  void zipDirectory(Directory dir,

My env:

Flutter 3.19.0 โ€ข channel stable โ€ข https://github.com/flutter/flutter.git
Framework โ€ข revision bae5e49bc2 (4 weeks ago) โ€ข 2024-02-13 17:46:18 -0800
Engine โ€ข revision 04817c99c9
Tools โ€ข Dart 3.3.0 โ€ข DevTools 2.31.1

Looking for a replacement method to encode/decode the ( phrase || privateKey ) <> keystore

Thinking about the keystore file format compatible to ethereum's system, however is not so efficiency. But it still worth finding a replacement to the format.

In dart, to implement the keystore encode/decode, one has to combine the scrypt and pbkdf2 to it. The easiest way to complete the job is to borrow the code from web3dart or laksadart I previously built for Zilliqa. However the encoding speed is too slow because of scrypt algorithm is slow.

Another option is to use FFI from other native library like ethsign , it is fast and run smoothly when I tried to bind it to the dynamic library. However, in rust we generally use serde_json to encode the Crypto object, the serde_json will be binded too, which will largely increase the bundle's size.

I don't have enough time to do enough search to finish the task. So if you have idea or solution, please comment or reply.

  1. A replacement standard or format for keystore.
  2. A fast and efficient way to encode/decode using FFI or pure dart code.
  3. Any other good ideas

Finish porting core features from "agent-js"

** updates**

  1. Candid UI is not needed
  2. Candid parser should be separate package as a builder

TODO:
[x] auth-client, used for authenticate a flutter app from Internet Identity authing app. tracking this issue: Changes will be required for Internet Identity, adapt to use a web pop window to receive callback
[x] wallet, keysmith, rosetta-api packages implemented

[] candid-ui/candid core, used for generating default ui like the web version
[] candid-parser, used for automated generating Candid file to dart code. Either we use candid-rs build script or use source_gen of flutter tool chain.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.